Mike Richards added his 10th goal for Philadelphia. Trent Hunter had a first-period goal for Islanders, and former Flyers goalie Martin Biron stopped 26 shots.
Jeff Carter set up Hartnell's eighth goal. Carter skated near the bench-side boards before sliding a backhand pass to an open Hartnell between the top of the circles. Hartnell's blast nestled above Biron's shoulder for the winner as Philadelphia snapped a three-game losing streak to finish 2-3 on a five-game trip.
New York had just one third-period shot in returning home after a seven-game trip in which it picked up eight out of a possible 14 points. Rookie John Tavares had an assist for the Islanders in their first home game since Nov. 7.
After Toronto outshot the Islanders by 40 in a New York victory, the Islanders built a 29-28 edge in shots over the Flyers. That marked the first time in seven games the Islanders produced more chances than the opposition.
But Philadelphia tightened up defensively in the third, holding the Islanders without a shot for the first 11:33.
Islanders goalie Dwayne Roloson was on the bench two days after his 58-save effort against Toronto. Biron, who played 133 games for the Flyers the previous three seasons, made 10 third period saves to keep his new club in it.
The Islanders ended a 0-16 skid on the power play when Hunter fired a left-circle one-timer from Tavares past Boucher 8:05 in. Hunter's fifth goal in seven games ended New York's four-game power-play drought.
Without leading goal-scorer Daniel Briere, Philadelphia struggled to generate offense until Richard's power-play goal made it 1-all with 33.8 seconds remaining in the second period.
Briere served the first of his two-game suspension for his late hit on Colorado Avalanche defenseman Scott Hannan. But Richards compensated, notching his 10th goal by one-timing Claude Giroux's slot pass from the low-right circle.