The Flyers blew leads of 2-0 and 3-2 before Hartnell put them ahead for good late in the third period. The Flyers open defense of their conference championship next week against the No. 7 seed - likely the Buffalo Sabres.
Even with 47 wins, the Flyers are stumbling into the playoffs. They failed to hold leads against one of the worst teams in the league and yanked postseason starting goalie Sergei Bobrovsky, but snapped a five-game losing streak (0-3-2) and ended a six-game skid at home (0-2-4).
The Flyers won the division for the first time since 2003-04 - a minor consolation after they squandered their lead atop the East to Washington with the late-season swoon.
Kimmo Timonen and Danny Briere also scored for the Flyers. Darroll Powe added an empty-netter with 1 second left.
Michael Grabner, Travis Hamonic, John Tavares and P.A. Parenteau scored for the Islanders. The Islanders finished 30-39-13 and with 73 points. Only Florida was worse in the East.
Philadelphia's slump may not mean anything once the playoffs start. The Flyers ended last season losers of eight of 12, but turned the corner in the playoffs and reached Game 6 of the Stanley Cup finals before losing to Chicago.
But pulling Bobrovsky in the finale can't make the Flyers faithful who have waited since 1975 for a Stanley Cup championship feel good about their chances.
The Flyers needed 47 seconds to score the first two goals of the game and the No. 2 seed seemed a mere formality. Instead, Bobrovsky coughed up the lead and was replaced late in the first period after allowing three goals on 10 shots.
Brian Boucher gave up one more goal in relief, but was bailed out by Hartnell's first two-goal game since Jan. 11.
The Flyers improved to 24-2 against the Islanders since the start of the 2007-08 season.
With a loss, the Flyers would have been forced to wait until Pittsburgh's finale on Sunday to find out if they would still win the division or finish no worse than fourth in the East.
Instead, they can start prepping for the postseason.
Philly opened as if it couldn't wait to get there. Timonen blasted his sixth goal of the year from the high slot 16 seconds into the game. Hartnell's first goal of the game at the 47-second mark came off a breakaway for a 2-0 lead.
The Islanders called a 30-second timeout and another sellout crowd was roaring in celebration.
Bobrovsky couldn't make it last.
Ville Leino's turnover at center ice led to Grabner's 34th goal - and meant the Flyers finished the season without a shutout. Hamonic scored on a one-timer on the power play for his fifth goal to the tie it.
Briere stole the puck at the blue line and his backhander made it 3-2 before the first period was even at the halfway point.
When Tavares tied the game with his 29th goal, that was all Flyers coach Peter Laviolette could stomach of his rookie goalie. He called on Boucher after passing over the veteran for the starting job in the postseason. Boucher started last year's postseason as Philadelphia's No. 1 goalie before an injury knocked him out.
The swap meet continued in the second: Parenteau pounded in a rebound for a 4-3 lead; Meszaros tied it with a shot through traffic.
Hartnell's 24th goal of the year with 1:31 left in the third put the Flyers ahead 5-4 and they wouldn't trail again. Meszaros added an insurance goal in the third.
Notes: The Flyers presented their team awards before the game. Claude Giroux was named MVP, Meszaros was top defenseman, Andreas Nodl was most improved, Boucher was the Flyer who best illustrates character, dignity and respect for the sport both on and off the ice. ... Parenteau had gone 14 games without a goal.