Toronto Maple Leafs coach Mike Babcock knows goaltender Frederik Andersen was the difference between two points or a home loss against the Calgary Flames.

Andersen stopped a season-high 47 shots through regulation and overtime, and three more in the shootout as Toronto beat Calgary 2-1 on Wednesday for its second win over the Flames in eight days.

William Nylander scored the winner in the fourth round of the shootout, deking to the backhand to beat Mike Smith.

"I didn't think we had very good legs. We looked like a team that came back from a road trip even though we had days to recover," said Babcock, who watched him team get outplayed for large chunks of the night and outshot 48-29.

"I thought we'd get traction and take over but that didn't happen... In the end our goalie was better."

Both teams had scoring chances in the extra period, with 3-on-3 play opening the ice. But Andersen came up with some clutch stops at the right moment to give Nylander a chance to win in it the shootout.

"In particular in overtime we gave up some Grade-A chances," said Babcock.

"I just want to take it one game at a time, real important to be able to flip the page," said Andersen, who has a .954 save percentage in his last nine games.

Morgan Rielly scored for the Maple Leafs (18-10-1), who also downed Calgary 4-1 on Nov. 28.

Mark Giordano scored for the Flames (14-12-2), who have dropped three in a row. Smith stopped 28 shots in a losing cause.

"We did exactly what we wanted to do, played with energy, put pucks on the net," said Giordano. "If we play like that we'll get two points more often than not."

Toronto centre Tyler Bozak was back in the lineup after missing two games and was placed on a line between James van Riemsdyk and Mitch Marner to start the game.

Calgary had control early in the contest when Toronto's Matt Martin went to the box midway through the first period.

And Giordano made Martin pay for his hooking penalty when his wrist shot from the point went through traffic and beat Andersen for the game's first goal at 10:37.

Later in the period, Martin checked Troy Brouwer into the boards between the benches, leading to a brief scrum. Flames forward Matthew Tkachuk appeared to spear Martin from the bench while the altercation ensued, but it went undetected by officials. Martin said post-game that he didn't feel it and was told about the play by a staff.

"You can play with an edge for sure, I think he's an effective player, good player," said Martin. "Whether the league wants to look at it is up to them. I don't think it's a good hockey play but I'll be all right."

Sean Monahan almost doubled Calgary's lead seven minutes into the second only for Andersen to turn him away from between the hash marks.

Andersen was there again to bail out his teammates late in the period on a Toronto power play when Calgary had a 2-on-1 short-handed break after Marner turned the puck over at the Flames blue line.

Rielly finally evened the score with 1:13 to play in the second, with his shot from the sideboards beating a screened Smith blocker side.

Tkachuk continued to agitate as the game went on and took a couple shoves from Andersen after crashing the net late in the second. On his final shift of the period, he drew a cross-checking call on Jake Gardiner in the corner that set up a Flames power play to start the third.

Monahan thought he regained the lead for Calgary 5:10 into the third but a video review confirmed the officials' original no-goal call because the net was off its moorings before the puck crossed the goal-line.

The Flames took it to the Leafs in the final 20 minutes, at one point outshooting Toronto 14-3, and held a 43-28 shots advantage heading into overtime.

"I thought it was a good hockey game, I look at how our team played start to finish I like our game," said Flames coach Glen Gulutzan.

"From our (defence), all six, to all four lines, I thought contributed. It was a good road game for us. We'd like the two points but it didn't happen."