Calgary's Michael Frolik celebrates a goal on Edmonton Oilers' goalie Cam Talbot during the first period in Edmonton, Alberta, on Saturday.

Jason Franson CP

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

Michael Frolik scored his third goal of the game with 8.7 seconds left and the Flames beat the Edmonton Oilers 5-4 to snap a four-game losing streak.

More from FoxSports

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 between Cam Talbot and the post for his first career hat trick.

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

Brandon Bollig and TJ Brodie also scored for the Flames, who were playing their third game in four nights.

Taylor Hall, Brandon Davidson, Teddy Purcell and Leon Draisaitl scored for Edmonton, which has dropped four of five.

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 8 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."

The Oilers trailed 4-2 heading into the third, but Purcell got a power-play goal 48 seconds into the period. Edmonton then tied it when Draisaitl got a perfect saucer pass from Hall and finished a 3-on-1 at 6:40 for his third goal in just two games this season.

Calgary had a goal disallowed when David Jones was ruled to have interfered with Talbot as a Brodie shot went in. But it managed to get the two points on Frolik's goal at the end.

Calgary got off to a fast start. Bollig tipped a Brodie shot past Talbot at 1:58, and Frolik's first goal of the season made it 2-0 with 8:26 left in the period.

Talbot coughed up the puck behind the net to Matt Stajan, and he sent it in front to Frolik, who scored into a wide-open net.

Edmonton got a goal back just over a minute later when Hall tipped Ryan Nugent-Hopkins' shot past Karri Ramo. But Frolik made it 3-1 at 17:27 when he redirected Kris Russell's shot into the net.

The Oilers appeared to have a power-play goal four minutes into the second, but Benoit Pouliot's score 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. Davidson scored on a drive from the point.

The Flames responded with a power-play goal of their own. The puck came back to a pinching Brodie, who scored on a slap shot.

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