The Calgary Flames were a team in need of a spark, and they got one at the perfect time on Saturday.

Michael Frolik scored three times — including the winner with 8.7 seconds remaining — as the Flames snapped a four-game winless skid by edging the Edmonton Oilers 5-4.

Frolik's winner was one that Edmonton goaltender Cam Talbot would have wanted back. Calgary negated an icing call in the final seconds and Frolik put a seemingly harmless shot on net from behind the goal line that squeezed in between Talbot and the post for his first career hat trick, and the two points.

"The puck was rimmed in and [Matt] Stajan went to battle and I kind of came to help him," Frolik said. "I had a bit of a battle and I just tried to shoot it off his pads and it went in. it was kind of a lucky goal, but it was a big one.

"They came back but we stuck with it. It was a big goal and hopefully this is going to get us going and hopefully we can keep going."

Brandon Bollig and TJ Brodie also scored for the Flames (3-8-1), who were playing their third game in four nights.

Taylor Hall, Brandon Davidson, Teddy Purcell and Leon Draisaitl responded for the Oilers (4-8-0), who have lost four of their last five.

Hall and Draisaitl tacked on two assists apiece for three-point outings while Connor McDavid was held off the scoreboard, halting his seven-game point streak.

Talbot took responsibility for allowing the late goal.

"There's no excuses, that puck can't cross the line," he said. "Points aren't easy to come by and we did a great job of battling back in the third. It's just really deflating giving up that goal with eight seconds left.

"We were close to a point and able to fight for a second one [in overtime] and we come out with nothing thanks to me."

Oilers head coach Todd McLellan said his team can't afford to put themselves in that position in the first place.

"When you give up five goals, you're not winning in this league, it's as simple as that," he said. "It doesn't matter how they happen, where they come from, what time of the game they come from, you don't win giving up five."

Calgary scored on its first shot of the game two minutes into the first as Bollig tipped a Brodie shot past Talbot.

The Flames went up 2-0 with eight-and-a-half minutes left in the opening period as Talbot coughed up the puck behind the net to Stajan and he sent it in front to Frolik, who scored his first of the season into a wide-open net.

Edmonton got a goal back just over a minute later as Hall tipped a Ryan Nugent-Hopkins shot past Flames goalie Karri Ramo.

Calgary made it 3-1 late in the first as a Kris Russell shot was directed in by Frolik.