Shanahan scored on New York's second shootout attempt and beat Martin Biron to give the Rangers their third shootout win of the season.
Shanahan, Fedor Tyutin and Petr Prucha scored for the Rangers in regulation, helping them move into a tie with the Flyers for first place in the Atlantic Division.
Jim Dowd, Danny Briere and Denis Tolpeko scored for the Flyers, who were hoping to move to 7-0 at home for the first time since the 1986-87 season.
The Flyers, who were getting badly outshot again much like they have all season, started attacking Rangers goalie Henrik Lundqvist midway through the third. But he made some amazing saves that nearly silenced Philadelphia's momentum.
Tolpeko, though, changed all that with his first career goal. Jason Smith's shot bounced off Lundqvist and Tolpeko was ready near the crease to slip in the puck and even the score at 3.
Prucha ended a scoreless drought that stretched back to opening night with a slapshot early in the third that put the Rangers ahead 3-2.
Both teams were feeling a bit feisty in a game between the Atlantic Division rivals that had several skirmishes. Colton Orr and Riley Cote each got 5 minutes for fighting in the first period that seemed to set the pace for a game that had more than a dozen trips to the penalty box.
The Flyers had to rally in the second period, too.
Briere gave the Flyers a boost late in the second and tied the score at 2. The puck slid his way after a faceoff and his slapshot past Lundqvist gave him his seventh goal of the season.
On a play that was nearly a rerun of their first-period goal, Shanahan flicked a short pass from Scott Gomez over Biron's left shoulder 1:47 into the second for his sixth goal of the season and a 2-1 lead.
Maybe the Flyers still need to convince their fans that last season's disaster was nothing more than aberration because there were still a surprising number of patches of empty seats.
Dowd jolted the crowd only 3:23 into the game when he scored his first goal in 11 games, knocking the puck off Lundqvist's left leg for a 1-0 lead.
The Rangers tied the score on a perfect one-timer from Gomez to Tyutin in the left circle.





