The result ended the Pens' (44-21-6) 11-game winning streak and stalled their chance to join the New York Rangers at the top of the Eastern Conference standings.
With 11 games to go in the regular season, the Penguins now trail the Rangers by one point while the Flyers (42-22-8) are a further two points behind Pittsburgh in the Atlantic Division, although they have played one extra game.
"With Sidney (Crosby) back, and Malkin, who is one of the best players in the world (it was nice) to come back and win like that," Hartnell told reporters.
"It's never easy in this league, especially against Pittsburgh."
Pittsburgh, with Crosby playing his third game since his comeback from injury, looked to have the result under control after leading 2-0 with goals from Craig Adams and NHL points leader Evgeni Malkin.
But the Flyers cut the margin to one when Kimmo Timonen then tied it up when Hartnell scored early in the third period. The game was headed to a shootout when Hartnell took a pass across the ice from Danny Briere and scored his second to decide the result.
Ilya Bryzgalov helped trip up Pittsburgh with 38 saves. Marc-Andre Fleury had 24 saves for the Pens.
The Penguins had been on fire with the second longest winning streak in their franchise history. Crosby had recorded four assists in his previous two games back but went without a point against the Flyers.
"During the streak, you probably couldn't have told our team we were on a streak," Penguins coach Dan Bylsma said. "We just picked up and go to the next game."