Hartnell took a nice cross-ice feed from Danny Briere to beat Marc-Andre Fleury with 0.9 seconds left on the clock.
Kimmo Timonen also scored to help the Flyers rally from a 2-0 hole against the hottest team in the NHL.
Evgeni Malkin and Craig Adams each scored for the Penguins. Sidney Crosby played in the third game of his comeback following a three-month absence caused by recurring concussion symptoms.
The Penguins lost for the first time since Feb. 19.
Hartnell and Timonen scored goals in the third period to rally against a weary Pittsburgh team playing their third road game in four days.
The Penguins lost their chance to move into a tie with the slumping New York Rangers for first place in the Eastern Conference. One day after losing a shootout in Boston, the Flyers moved two points behind Pittsburgh and three behind the Rangers.
Because of penalties, the overtime began with some 3-on-3 hockey. Hartnell ended it with his 35th goal and an even rarer feat - a Penguins loss.
There was a playoff atmosphere from the start of the nationally televised game - the first of three between the rivals at the tail end of the regular season. Hartnell and Chris Kunitz traded blows as part of a multi-player melee in the third, a sign of rising tensions as the postseason nears.
Crosby's presence added some spice to the series and Flyers fans let Crosby hear it early. No. 87 wasn't even on the ice when a derogatory chant about him was bellowed from the upper deck. Crosby, long a thorn in Philadelphia's sweater, was booed the moment he hit the ice for his first shift.
The Penguins started the NHL's longest winning streak of the season without Crosby and could be the team to beat in the East once The Kid rounds into form.
Crosby, who had five assists in his first two games back, failed to earn a point and didn't make an impact against a Flyers team that took two periods to find their groove. The Flyers failed to take a shot in the second until 4:47 remained in the period, and they went nearly 18 minutes without a shot overall.
The Flyers were booed off the ice in the second intermission by their restless fans.
It didn't take long to turn that around. Timonen blasted a shot from the point past Fleury for his third goal of the season only 31 seconds into the third to make it 2-1.
Hartnell tied it minutes later when he aimed high on a tough angle shot from the goal line that made it 2-all.
Fleury had 25 saves for the Penguins, who wasted a fast start in one of the tougher road atmospheres in hockey.
Adams tipped in Kris Letang's shot from the point for his fifth goal and the early 1-0 lead. Malkin made an MVP-caliber move when he took the puck completely around the crease and slid it under Ilya Bryzgalov's right leg for a 2-0 lead with 53 seconds left in the second period.
Bryzgalov stopped 38 shots and turned away Crosby in the first. Crosby also had a pass intercepted by Flyers defenseman Matt Read.
The Flyers improved to 3-1 against the Penguins this season.
Notes: The Flyers played without F Max Talbot (undisclosed injury) and D Andreas Lilja (throat). ... The Flyers were outshot 40-27.