McDavid's game-winner past Ryan Miller's stick side came after Anaheim's Rickard Rakell and Edmonton's Leon Draisaitl earlier traded goals in the shootout.
Rakell scored a hat trick, including two goals in the final 21 seconds to send the game into overtime
Ryan Strome scored two goals, McDavid had three assists and Draisaitl had a goal and an assist for Edmonton, which won its third straight game and swept its back-to-back weekend trip to Los Angeles and Anaheim.
Anton Slepyshev and Iiro Pakarinen also scored goals for the Oilers, and Michael Cammalleri added two assists. Edmonton goalie Al Montoya made 41 saves.
Ryan Getzlaf had a goal and three assists, and Adam Henrique also scored for Anaheim, which lost for just the second time in its past 13 home games (10-2-1) against the Oilers. Corey Perry logged three assists, and Miller finished with 37 saves for the Ducks.
Strome scored a pair of goals, both off passes from McDavid, in the second period and early in the third period to give the Oilers a 4-2.
Getzlaf cut the deficit to 4-3 with his ninth goal of the season with six minutes left, but Pakarinen put Edmonton back up 5-3 with 4:20 left, converting a pass through the crease from McDavid.
Rakell, who scored his first goal in nine games earlier in the contest, scored two goals in less than 15 seconds to send the game into overtime, the final one coming on a rebound with just seven seconds left.
Edmonton, taking advantage of a rare Getzlaf gaffe at center ice, needed just 13 seconds to take a 1-0 lead. Getzlaf passed the puck directly to Cammalleri, who then quickly fed Draisaitl breaking in alone from the right side, where he fired a shot through Miller's pads.
It was the third-fastest goal to start a game this season. Tyler Pitlick of the Dallas Stars scored in 10 seconds in a 5-3 loss to the Winnipeg Jets on Saturday night, and the Minnesota Wild's Nino Niederreiter did it in 12 seconds in a 3-0 win over the Philadelphia Flyers on Nov. 14.
However, the Oilers didn't have much time to celebrate as Rakell tied it at 1:46. He slammed a pass from Getzlaf from the right side of the net through Montoya's pads, his 23rd goal of the season.
Slepyshev made it 2-1, taking a pass from McDavid from behind the net and firing it between the post and Miller's glove hand at 12:55 of the first period.
The Ducks tied it 2-2 early in the second period on with a power-play goal from Henrique, who blasted a shot from the right point past a double screen in front of Montoya.
--Field Level Media
Edmonton | Anaheim | |
Connor McDavid 3 | Points | Ryan Getzlaf 4 |
Ryan Strome 2 | Goals | Rickard Rakell 3 |
Connor McDavid 3 | Assists | Ryan Getzlaf 3 |
N/A | Power Play Goals | Adam Henrique 1 |
N/A | Short Handed Goals | N/A |
Al Montoya .891 | Save Percentage | Ryan Miller .881 |
Al Montoya 41 | Saves | Ryan Miller 37 |
Team | Shots | Goals | Power Play | Penalty Kill | Penalty Mins | Face Offs Won |
Edmonton | 42 | 6 | 0-2 | 2-3 | 6 | 35 |
Anaheim | 46 | 5 | 1-3 | 2-2 | 4 | 32 |