The dramatic ending allowed the Devils to end a six-game losing streak after they had faced a two-goal deficit with time running down in the third period.
Jhonas Enroth shut out the Devils for 53:30, but gave up a power-play goal to Adam Henrique that brought New Jersey within one.
Elias then forced overtime with his seventh goal of the season.
The Devils had not won since Feb. 21, when they posted a 3-2 decision over Washington. Hedberg made 23 saves in regulation and overtime.
Moore to attend retreat in to avoid Kutcher's wedding
Easer Egg Roll brings thousands to White House