Ilya Bryzgalov made 13 saves in the third period to fight off the Penguins. Philadelphia jumped past Pittsburgh into the lead in the Atlantic Division.
Hartnell's goal came with 6:28 to go in the middle stanza.
Bryzgalov stopped 25 shots overall and Marc-Andre Fleury made 26 saves for the Penguins, who have lost three out of five.
Pittsburgh played without team captain Sidney Crosby, who sat out the game as a precaution after colliding with teammate Chris Kunitz Monday in a loss to Boston. Crosby will also miss Saturday's meeting with the New York Islanders.
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'
Couple mistakenly served bag of cash at McDonald's drive-thru