Hartnell set up to the left of Stars goalie Kari Lehtonen, and Jeff Carter's shot deflected off Hartnell, off the goal post, and over the goal line at 7:55.
Simon Gagne and Mike Richards had a goal and an assist each for the Flyers, who won on the road for the first time in five games.
Brian Boucher made 25 saves after the Flyers learned earlier in the day that top goalie Michael Leighton will be out at least eight weeks because of a high ankle sprain. Leighton was injured Tuesday night in a 4-3 shootout loss at Nashville.
An MRI on Thursday revealed the extent of the injury, which will sideline Leighton for the rest of the regular season and at least the opening round of the playoffs.
Boucher was playing in his fifth game since his last start on Dec. 21.
The Flyers strengthened their grip on a playoff spot, improving to 79 points.
Lehtonen stopped 28 shots, and Steve Ott had both goals for the Stars, seven points behind No. 8 Detroit for the final Western Conference playoff spot.
Ott also had two goals in Dallas' only other meeting with the Flyers this season, a 6-3 Philadelphia win on Jan. 12. The Stars are 2-6-1 since the Olympic break and have 12 games left.
Ott gave Dallas the lead on the power play at 9:41 of the first period with a one-timer from the high slot.
Gagne tied it at 1 at 15:01 of the opening period when he jammed a rebound past Lehtonen.
Ott took a cross-ice feed from Nicklas Grossman and fired into an open net to put Dallas in front at 17:55 of the first period. Richards drew Philadelphia even at 2 when he converted a 2-on-1 break with Gagne at 5:27 of the second period, Richards' 27th of the season.
NOTES: Lehtonen is 0-9-1 for his career against Philadelphia, with the first nine decisions coming with Atlanta. ... The Flyers were making the third stop of a four-game trip. The Stars played the fourth game of a six-game homestand. ... Dallas C Mike Modano missed his second straight game. Modano is recovering from an appendectomy earlier in the week. ... Philadelphia's last game in Dallas was on March 13, 2007. ... Gagne has eight goals in his last nine games.