After trailing 2-0 in the second period, the Flyers roared back with the next three scores to break the Penguins' NHL-best 11-game winning streak.
Kimmo Timonen's power-play marker 31 seconds into the third period cut the Flyers' deficit in half, and Hartnell netted the equalizer, his 34th goal of the season, 4 minutes later.
Then with the clock winding down in overtime, Danny Briere found an unmarked Hartnell alone in the slot and the Flyers left wing blasted it past Pittsburgh netminder Marc-Andre Fleury for the game-winner.
Ilya Bryzgalov turned aside 38-of-40 shots for Philadelphia, which at 92 points pulled to within two of the Pens in the Atlantic Division and Eastern Conference standings.
Fleury finished with 24 saves.