EDMONTON - 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.

The Oilers looked to have cashed in on a power play four minutes into the second period on a goal by Benoit Pouliot, but it was overturned on a ruling of contact with the goalie.

Edmonton made up for the tough call on another power play midway through the second as Davidson scored on a point blast.

The Flames responded on a power play of their own as the puck came back to a pinching Brodie and he scored on a slap shot.

The Oilers made it 4-3 with the man advantage 48 seconds into the third period as a puck came through traffic to Purcell at the side of the net for the goal.

It was Calgary's turn to have a goal disallowed soon after as David Jones was ruled to have interfered with Talbot as a shot from Brodie went in past Talbot.

Edmonton tied the game 6:40 into the third on a three-on-one as Hall made a perfect saucer pass to Draisaitl, who scored his third goal in just two games played this season.

Ramo finished with 19 saves for the win while Talbot turned aside 27-of-32 shots in defeat.

Both teams are off until Tuesday, when the Oilers host the Philadelphia Flyers and the Flames travel to Colorado to face the Avalanche.