The Flyers overcame a three-goal deficit to spoil the debut of Anaheim's new head coach Bruce Boudreau. He was fired as the head coach of the Washington Capitals on Monday and quickly hired by Anaheim early Thursday morning.
Jaromir Jagr had two goals and an assist for the Flyers, winners in three of their last four games.
Ilya Bryzgalov stopped 19-of-22 shots to earn the win.
"We didn't play well in the first period," Flyers defenseman Kimmo Timonen said. "With a new coach they came out hard, but we deserved the two points tonight."
Jonas Hiller allowed all four goals on 47 shots.
After Anaheim failed to convert on a power play that stretched into the extra frame from the third period, the Ducks' Ryan Getzlaf was whistled for a tripping penalty 41 seconds into overtime and then handed an unsportsmanlike conduct penalty to give Philadelphia a four-minute power play.
The Ducks killed off the first penalty and almost made their way through the second before Danny Briere sent a cross-ice pass to Giroux near the left boards and he hammered a one-timer into the short side for the game-winner.
Anaheim took a two-goal lead into the first intermission thanks to Cogliano one-handing a shot through the legs of Bryzgalov for a power-play goal at the 8:12 mark and Selanne's one-timer from in front of the net just over two minutes later.
Gordon's goal came off a rebound 6:31 into the second to give the Ducks a 3-0 lead.
Jagr then took advantage of two power play opportunities to get the Flyers within one.
His first came with 4:42 left in the second when Timonen's shot from the high slot deflected off Jagr's thigh and skipped through the legs of Hiller. The second came early in the third on a quick shot from the right circle that sailed into the net on a two-man advantage.
Scott Hartnell knotted the game at three with 3:02 left in regulation on a one-timer from the right of the goal to necessitate overtime.
"The bottom line tonight was too many penalties. We did a lot of positive things, but we took too many penalties," Selanne said. "We have got to play smart."
The last time the Flyers won in Anaheim was a a 5-4 shootout victory on January 2, 2009...Prior to Friday, the Flyers' last power play goal was on November 23...Saku Koivu had two assists for Anaheim...Timonen had three helpers in the game.