Andy Greene had his first career goal, and Sergei Brylin and Travis Zajac also scored for the Devils, who had lost three in a row but have reached 90 points. New Jersey beat the second-place Penguins in Pittsburgh for the second time in 10 days.
Evgeni Malkin, Sergei Gonchar and Michel Ouellet scored for the Penguins, who had won three of four but fell two points behind Ottawa for the No. 4 seed in the Eastern Conference playoff race.
The left-shooting Elias skated far to his right on Penguins goalie Marc-Andre Fleury as the final shooter in the shootout. He skated from Fleury's left to his right before flipping the puck past him.
New Jersey's Martin Brodeur stopped Pittsburgh's Erik Christensen, Malkin and Sidney Crosby to earn his 40th win of the season. Brodeur has won 40 games for the sixth time and became the only goaltender to win 40 in consecutive seasons on multiple occasions.
Ouellet tied the game with 3:38 to play after Malkin intercepted an ill-advised pass by Scott Gomez behind the Devils goal line. Gomez was trying to get the puck to Greene, who was behind the net.
But Malkin stole the puck and fed Ouellet, who was skating alone down the slot and one-timed a slap shot high to the stick side of Brodeur.
The game took place while the Penguins' owners, state and local politicians and NHL officials were meeting across the state in Philadelphia in talks aimed at funding a new arena for Pittsburgh. If talks collapse, the team could end up relocating in Kansas City or another city after the season.
Fans in the sellout crowd of 17,132 started a "Save Our Pens" chant less than a minute into the game, and there were a handful of banners hanging from the balcony seating ranging from being anti-Pennsylvania Governor Ed Rendell or anti-Kansas City to pro-Penguins and pro-Pittsburgh.
Those fans had reason to cheer 6:48 into the game when Malkin scored while on the power play. Brodeur's stick got a piece of a Mark Recchi shot, and the puck deflected to an open Malkin, who scored his 30th of the season - tops among NHL rookies.
Greene tied the game 3½ minutes into the second period when Fleury never saw the defenceman's wrist shot from the point while New Jersey was on the power play.
Brylin gave the Devils their first lead by scoring while sprawled out on the ice.
Johnny Oduya took a shot from the left point off pass from Gomez, who won a faceoff to the right of Fleury. Fleury made the initial save but Brylin dove to the right for the rebound and - while stretched out on the ice - slapped the puck into the net for his 15th goal of the season.
But Gonchar tied the game 2-2 with a short-handed goal 7:32 into the final period. Alone along the right boards, he threw what appeared to be an innocuous shot toward Brodeur but somehow slipped through his pads.
New Jersey took a short-lived lead four minutes later, when a Jamie Langenbrunner shot was juggled by Fleury. Zajac, standing to the left of Fleury, found a way to get the rebound past him.
Notes: Greene scored his first goal in his 10th career game. ... Thirteen of the Penguins' past 14 games have been decided by one goal. ... The assist was Rafalski's 300th career point. .... Devils entered the game averaging only 10.3 penalty minutes per game, least in the NHL.