It was the second hat trick of the season for Lindros and the first in Gagne's career.
The Rangers took sole possession of the eighth and final playoff spot in the Eastern Conference.
Lindros, who was acquired by the Rangers from the Flyers on Aug. 20 along with future considerations for Kim Johnsson, Pavel Brendl, Jan Hlavac and a draft pick, completed his hat trick 2:12 into the second period. Mike York assisted on all three of Lindros' goals as New York opened a 4-0 lead.
But the 21-year-old Gagne completed his hat trick with 7:55 left as the Flyers tallied three times in the final period, pulling within 6-5.
Mike Richter made 10 of his 26 saves in the third as the Rangers improved to 22-10-2-1 this season when Lindros collects at least one point in a game.
Flyers goaltender Roman Chechmanek left the contest 12:50 into the first period with a sprained right ankle. Brian Boucher yielded five goals in 20 shots in relief of the Czech Olympian.
Flyers defenseman Eric Desjardins scored 29 seconds into the third period to record the 500th point of his NHL career.
Wisconsin business offering 'therapeutic cuddling' forced to close
Workers accuse National Zoo of animal mismanagement