John Tavares also scored for New York, which won its fourth straight on the road while improving to 10-4-1 away from home this season to pull into a tie with the Rangers for the eighth and final playoff spot in the Eastern Conference.
Scott Hartnell scored twice and Mike Knuble also tallied for the Flyers, who blew a two-goal lead while falling further out of the playoff picture. Philadelphia last missed the playoffs in 2007.
The Isles, who last made the playoffs in 2007, dominated the final two periods of regulation after falling behind 2-0 in the first period.
McDonald tied the game at 2 with 9:56 left in the final period when his one-timer from close range after Keith Aucoin's pass from behind the net beat Ilya Bryzgalov on the stick side.
McDonald scored again from the point 5? minutes later when his slap shot deflected off the skates of Flyers defenseman Bruno Gervais and past Bryzgalov to put New York ahead 3-2.
But the Flyers tied it with 29.8 seconds left in regulation when Hartnell tallied on the power play with Bryzgalov pulled. New York goalie Evgeni Nabokov appeared to have the puck frozen, but it was knocked loose and to Hartnell in front of the left post. Hartnell corralled the puck with his skates and then knocked it past a sprawled Nabokov.
After a scoreless overtime period, the teams each scored once in the regulation period of the shootout. After Philadelphia's Wayne Simmonds missed his attempt in the fourth round, Bailey wristed a shot past Bryzgalov on the stick side to give New York two points.
The Flyers took a 2-0 lead after the first period on goals from Hartnell and Knuble. Hartnell opened the scoring by one-timing a pass from Giroux from the slot low and to Nabokov's glove side. Hartnell fanned a bit on the shot, shaking his head in mock disgust before smiling after the power-play tally.
Knuble, who was a healthy scratch in eight straight games and 10 of the last 11, put Philadelphia ahead two goals when he finished a 2-on-1 break by deking past Nabokov with a slick backhanded shot into a wide-open goal.
The Islanders nearly pulled within a goal when Andrew MacDonald's slap shot beat Bryzgalov, but the puck entered the net after the first-period buzzer had sounded to nullify the goal.
The Islanders scored their first goal with one minute left in the second period when Tavares netted his 21st goal of the season. Tavares, who began the day second in the league in goals scored, passed the puck toward the net and it caromed off the foot of Flyers defenseman Erik Gustafsson and past Bryzgalov.
Notes: Flyers defenseman Braydon Coburn left the game in the second period after suffering an upper-body injury and didn't return. ... Philadelphia entered having won 29 of the last 33 meetings with the Islanders. ... Giroux has tallied 23 points in his last 16 games against the Islanders.