Andrej Meszaros scored twice, Andy Hall, Jakub Voracek, and Matt Read also had goals, and Claude Giroux had two clutch assists for the Flyers.
Brock Nelson, Brian Strait, John Tavares and Cal Clutterbuck scored for New York, which had won eight of nine on the road and five of six overall.
On the day he signed a $12.3 million, three-year contract extension, Flyers goalie Steve Mason was yanked from the game after allowing four goals on 24 shots.
Ray Emery stopped the five shots he faced to earn the win in relief. The Flyers are 24-12-5 since a 1-7 start.
Raffl fired a shot past goalie Kevin Poulin after a backhanded, drop pass from Giroux to make it 5-4. Read added an empty-net goal.
The Flyers tied it at 4 when Voracek ripped a one-timer from the high slot past Poulin. Giroux also set that up with a perfect, backhanded pass.
Nelson and Strait scored 2:55 apart to turn a 3-2 deficit into a 4-3 Islanders lead in the second period. Nelson deflected Calvin de Haan's slap shot past Mason. Then Strait fired a slap shot just inside the far post, sending Mason to the bench.
Hall scored 3:45 into the second period to give Philadelphia a 3-2 lead. Hall deflected Mark Streit's slap shot over Poulin's shoulder for just his second goal in 47 games.
Mason preserved the lead when he stoned Michael Grabner on a 2-on-1 breakaway, sliding right-to-left and kicking the puck away with his left skate.
Shortly afterward, Tavares scored the tying goal but it was waved off because Thomas Vanek fell into Mason in the crease.
Less than three minutes after the Flyers fell behind 2-0, Meszaros scored his first goal. His shot from the bottom of the left circle hit Poulin's pad and went between his legs.
Meszaros made a nifty move to score his second goal and fourth of the season. He faked a shot from the top of the circle, skated around a defender and lifted one into the top corner for his third career two-goal game.
A healthy scratch 20 times this season, Meszaros has turned into an offensive force since returning to the lineup. He has three goals and eight assists in the last 10 games.
Tavares gave the Islanders a 1-0 lead, beating Mason with a wrist shot after a turnover by Philadelphia defenseman Nicklas Grossmann.
Another turnover by the Flyers led to Clutterbuck's short-handed goal. Voracek misplayed the puck at the point, Frans Nielsen skated down the left side and centered a pass to Clutterbuck for a wrister that beat Mason.
NOTES: Philadelphia is 15-2-2 in the past 19 games vs. the Islanders. ... The Flyers have allowed eight short-handed goals. ... The Islanders are 3-11-3 against the Metropolitan Division. .. The Isles fell to 17-5-2 when they score at least three goals. ... Meszaros last scored two goals in a game on April 9, 2011, against the Islanders.