McDavid gave the Oilers a 3-2 lead with a shot from the left face-off dot on the rush that bounced in off the far post.
McDavid had two assists, Kailer Yamamoto had a goal and an assist, and Mike Smith made 34 saves for Edmonton (15-11-0), which scored one goal when it lost three straight to the Toronto Maple Leafs to begin its seven-game homestand.
"It's a big win," McDavid said. "When you're sliding like we were, you have to find a way out of it, and I thought we did a great job as an entire group of just staying with it, sticking with it, holding on to that game even though we probably didn't get off to our best start."
Elias Lindholm had two assists, and Jacob Markstrom made 30 saves for Calgary (11-12-2), which is 3-6-1 in its past 10.
The Flames fired coach Geoff Ward on Thursday after a 7-3 win against the Ottawa Senators, replacing him with Darryl Sutter. Assistant Ryan Huska coached Calgary against Edmonton, with Sutter not expected to join the Flames until Monday at the earliest because of NHL COVID-19 protocols.
"I thought we gave up a little too much room as the game went on and we allowed them to get into our zone too easily," Huska said. "That's really how they got their three goals, in my opinion."
Johnny Gaudreau scored 33 seconds into a tripping penalty to Yamamoto to give Calgary a 1-0 lead at 14:49 of the first period. He one-timed a cross-ice pass from Lindholm.