It was a script Maple Leafs fans have seen before.

Earlier this week, in fact.

Up 3-1 in the third period and seemingly in complete control, Toronto allowed an opponent to wrestle the momentum away without much of a response for the second time in five days.

The Leafs managed to save face in this one, but plenty of questions remain for a team with Stanley Cup aspirations currently in a battle for its playoff life.

John Tavares scored his second goal of the night at 4:53 of overtime Friday as Toronto escaped with a 5-4 victory against Anaheim Ducks after blowing 3-1 and 4-3 leads in the final 20 minutes.

WATCH | Leafs sneak past Ducks in OT:

The Toronto Maple Leafs blew a 2-goal lead in the 3rd period, but managed to top the Anaheim Ducks 5-4 in overtime to salvage the win. 1:43

"It seems like we're just lacking some confidence in those situations," Leafs head coach Sheldon Keefe said after his team was outshot 15-4 in the third by a club playing the second of a back-to-back. "Almost like we're waiting or expecting something bad to happen.

"It's not what we want to be about."

Auston Matthews buried his 40th goal of the season to tie Alex Ovechkin for the NHL lead, while Jason Spezza and Andreas Johnsson, who was promoted to the top line with William Nylander out sick, provided the rest of the offence for Toronto (29-19-7). Matthews picked up three assists for a four-point performance, while Mitch Marner added three of his own. Tavares also had an assist.

Campbell gets 1st win

Jack Campbell made 26 saves in his first start for the Leafs following Wednesday's trade with the Los Angeles Kings.

"What a resilient group," said Campbell, who admitted to some early jitters. "That's a tough game when you give up the lead like that.

"But as a team you've got to appreciate the resilience."

Tavares scored his 22nd goal on a redirection at the lip of the crease with 6.2 seconds left on the clock in the extra period off a sweet Marner feed after Rickard Rakell went off for tripping.

"We just had to stay with it," Tavares said. "Not a very good third period. Not ideal and something we have to clean up."

Adam Henrique, with a goal and an assist, Nicolas Deslauriers, Max Jones and Derek Grant replied for Anaheim (22-26-7), which was playing its third game in four nights following Thursday's 3-2 overtime loss in Montreal.

Ryan Miller stopped 30 shots for the Ducks, who were forced to go with five defenceman for the third period and overtime after Erik Gudbranson left with an upper-body injury. Cam Fowler had two assists.

"We battled," Anaheim head coach Dallas Eakins said. "We fought hard and showed some great character."

The Leafs led 3-1 in the third Monday, but caved against the Florida Panthers — a team missing its best player in Aleksander Barkov — in a 5-3 loss.

'You take the good and the bad'

Toronto's victory Friday saw the club jump back into a playoff spot in third in the Atlantic Division, a point ahead of Florida, which has a game in hand.

"You just take the good and bad," Matthews said of a win tainted by another squandered lead. "We don't want to get in that position, and it's been a position that we've been falling into quite a bit."

After Terry scored shorthanded and Henrique, on a power play, added another just over four minutes apart to level things 3-3 midway through the third, Spezza got Toronto back in front when he raced down the right side, faked a shot on Miller, and scored his ninth upstairs from a tight angle with 3:28 left in regulation.

"That was an elite goal," Keefe said of the 36-year-old's effort. "He still hasn't lost that."

Auston Matthews, right, celebrates his goal with teammate Mitchell Marner during the second period. (Frank Gunn/The Canadian Press)

But Grant poked home his 13th with 57 seconds left on the clock off a scramble to knot it up again and force OT.

Campbell and bruising forward Kyle Clifford both made their debuts for the Leafs following Wednesday's deal that sent winger Trevor Moore and two draft picks the other way.

With No. 1 goalie Frederik Andersen still out nursing a neck injury suffered Monday and backup Michael Hutchinson unable to get the job done in Wednesday's 5-3 setback at the New York Rangers, Toronto general manager Kyle Dubas pulled the trigger with his team sitting below the post-season cutline.

Andersen won't make the trip to Montreal for Saturday's tilt, but could return next week after consecutive days on the ice. Keefe said he hadn't decided on his starter at the Bell Centre, but it seems likely Campbell will get the tap on the shoulder.

"We gave it back a little bit there in the third," Clifford said. "We want to lock the game down and suck the life out of them."

Matthews joins Maple Leafs lore

Tied 1-1 after the first, Tavares scored his third goal in as many games on a power play 3:38 into the second.

After the Leafs killed off a Tavares penalty midway through the second, the captain found Matthews off the rush, and he buried his 40th on a bullet one-timer at 13:18. The 22-year-old equalled the career-high 40 he scored in his rookie season back in 2016-17, and tied the 34-year-old Oveckhin's league lead in 2019-20.

He's also the fifth Leaf to record two 40-goal seasons with the team, joining Darryl Sittler, Frank Mahovlich, Lanny McDonald and Rick Vaive.

"It means a lot," Matthew said of reaching 40 in just 55 games. "It's a big tribute to those guys that I play with."

Expected to add some much-needed grit to Toronto's talent-loaded roster, Clifford mixed it up with Ducks captain Ryan Getzlaf during a scrum near Campbell's net.

WATCH | 9 NHL black history moments ... in 90 seconds:

Willie O'Ree broke the league's colour barrier in 1958, and there have been a lot of firsts since then. Rob Pizzo walks you through 9 trailblazers for Black History Month. 1:53

He got a rousing ovation from the 19,077 on hand at Scotiabank Arena as both men skated to the penalty box.

Campbell didn't have a lot to do through two periods as the Leafs kept things tight, but he had to be sharp on a couple of Fowler chances late in the second.

Anaheim came out strong in the third and Jones took advantage of a Johnsson turnover on Toronto power play before beating Campbell upstairs on a breakaway for his seventh at 8:34.

The Ducks tied it with 7:13 left in regulation when Henrique batted his 18th out of mid-air on a man advantage after Clifford went off for holding the stick.

"I don't think we skated well enough," Tavares said of the Toronto's third. "We didn't initiate the play and they came out with good energy."

It's something the Leafs know needs to change — and fast.