Elias scored 12:12 into the initial frame when he skated to the net and stuffed a shot past Brian Boucher into the corner of the net, giving the Devils a 2-0 lead.
Elias added an empty-netter, Henrik Tallinder also scored and Hedberg turned aside 26-of-27 shots as the suddenly hot Devils won for the fifth time in six games.
The Eastern Conference-leading Flyers, meanwhile, lost for only the second time in 10 games.
James Van Riemsdyk scored and Boucher stopped 19-of-21 shots for Philadelphia.
Swim Week Miami Beach 2014 [PHOTOS]