Giroux scored on a left-circle blast with 1 minute, 31 seconds left in overtime while the Flyers were on a four-on-three power play.
The Flyers' tied it at 3 when Hartnell, converting a Kimmo Timonen (three assists) behind-the-net pass, scored with 3:02 remaining in regulation.
The stunning turnaround ruined Bruce Boudreau's first game as Anaheim's head coach. Boudreau's first career win, back in 2007 with Washington, was against the Flyers. For most of Friday, it looked like his initial victory with Anaheim would also be against the orange and black.
The Flyers had three power-play goals for the second time this season.
"You're not going to beat that club if you take (11) minors," Boudreau said. "I played against them too many times. . . . They're the highest-scoring team in the league for a reason."
Playing their first game since last Saturday, the Flyers cut the deficit to 3-1 when Jagr scored on the power play, his first goal since Nov. 5. Jagr deflected Timonen's drive past goalie Jonas Hiller with 4:42 left in the second period.
"That's what we needed - one power-play goal to get the confidence," Jagr said after the 116th two-goal game of his career.
With the Flyers on a five-on-three power play, Jagr scored on a one-timer from the right circle, cutting the Ducks' lead to 3-2 with 15:14 left in the third period. It gave Jagr 654 career goals, two away from from Brendan Shanahan's total for 11th place in NHL history.
Hiller turned aside Jagr's bid for his first NHL hat trick since 2006 with 6:20 left in regulation.
The Flyers, who had seven rookies in their lineup because of injuries, played a strong second period, but they were flat in the opening 20 minutes as they fell into a 2-0 hole and allowed a power-play goal.
"The score was bad, but I didn't think we played that bad," Jagr said. "Some shifts, we cycled the puck real well."
Coach Peter Laviolette agreed.
"The only thing I didn't like in the first period was the score," he said. "We had shots, chances . . . and we got better in the second and better in the third."
The Flyers outshot the Ducks, 47-22.
Despite two goals and 10 shots on goal, Jagr said he is still rounding into game condition after missing most of the last five games.
"Some shifts, I thought I was going to puke," he said.
Laviolette praised his entire team.
"I thought all the lines were good. The young kids stepped up and played well. The fourth line gave us great energy shifts," said Laviolette, who sat many of his rookies in the final 10 minutes of regulation and the overtime. "[Danny Briere's] line was good. [Brayden] Schenn looked good. Lots of positives to take from tonight."
At the top of the list was the power play, which went 3 for 9, getting two goals from Jagr and the game-winner from Giroux after a double-minor to Ryan Getzlaf.
"It's been a while since we made a difference," Giroux said of the power play, which was 1 for 10 in its previous three games.
Bryzgalov, benched in the previous two-plus games, gave the Ducks momentum by allowing a soft power-play goal with 11:48 left in the opening period. He failed to pokecheck the puck away from Andrew Cogliano, who knocked it past him to give Anaheim a 1-0 lead.
About 21/2 minutes later, ageless Teemu Selanne got behind Braydon Coburn and tapped in Saku Koivu's goalmouth pass, giving the Ducks a 2-0 lead.
Anaheim made it 3-0 early in the second period when Bryzgalov served a juicy rebound that Andrew Gordon put into the net after the puck appeared to deflect off Flyers defenseman Marc-Andre Bourdon in front.
The Ducks' Matt Beleskey could face a disciplinary hearing for a flagrant boarding penalty that sent Sean Couturier to the ice in the opening period.
Contact staff writer Sam Carchidi at firstname.lastname@example.org or @BroadStBull on Twitter.