Carter scored his 40th goal and Gagne his 30th only 2:06 apart to hand Martin Brodeur only his third loss in 12 games since returning from biceps surgery.
The Flyers have won three straight behind goalie Martin Biron, and got a goal and an assist from Danny Briere.
Brendan Shanahan and Jamie Langenbrunner scored for New Jersey, which missed a chance to clinch a playoff spot.
Get Action News on your website