TORONTO -- For the second time this week, the Toronto Maple Leafs gave up a two-goal lead at home in the third period. This time, they recovered to get a win.
Auston Matthews got his 40th goal of the season to tie Alex Ovechkin for the NHL lead and had three assists, while Jason Spezza and Andreas Johnsson also scored for Toronto. Mitch Marner also had three assists and Tavares had one.
The Maple Leafs squandered leads of 3-1 and 4-3 in the third period.
"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."
On Monday night, Toronto took a 3-1 in the third against Florida before falling 5-3.
Jack Campbell made 26 saves in his first start for the Maple Leafs, two nights after being acquired from Los Angeles.
"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 of the season at the lip of the crease with 6.2 seconds left on the clock in the extra period after Rickard Rakell was sent 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 had a goal and an assist, and Nicolas Deslauriers, Max Jones and Derek Grant also scored for Anaheim. Cam Fowler had two assists and Ryan Miller finished with 30 saves for the Ducks, who were playing for the third time in four nights.
Anaheim was forced to go with five defenseman for the third period and overtime after Erik Gudbranson left with an upper-body injury.
"We battled," Anaheim coach Dallas Eakins said. "We fought hard and showed some great character."
The Maple Leafs led 3-1 after 40 minutes, but Jones scored short-handed and Henrique on a power play a little more than four minutes apart in the third to tie it.
Spezza got Toronto back in front 4-3 when he raced down the right side, faked a shot on Miller, and scored his ninth upstairs from a tight angle with 3:27 left in regulation.
But Grant scored his 13th with 57 seconds left on the clock off a scramble in Campbell's crease to knot it up again and force OT.
The win moved Toronto 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."
No. 1 goalie Frederik Andersen, recovering from a neck injury, won't make the trip to Montreal for Saturday's tilt with the Canadiens, but could return next week after consecutive days on the ice.
Tied 1-1 after the first period, Tavares scored his 21st, and third in thre games, on a power play 3:38 into the second off a pass from Matthews.
Toronto started to impose its will from there, with Marner nearly connecting after an incredible dangle around Jakob Silfverberg before Matthews came close on two chances.
After the Maple Leafs killed off a Tavares penalty midway through the second, the captain found Matthews off the rush, and he buried his 40th on a one-timer at 13:18 to make it 3-1. The 22-year-old equalled the career-high 40 goals he scored in his rookie season in 2016-17, and tied the 34-year-old Oveckhin's 40 for the overall lead in 2019-20.
He's also the fifth Maple Leafs player 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."
Campbell didn't have a lot to do through two periods as Toronto kept things tight in front of its new goalie, but had to be sharp on a couple of chances by Fowler late in the second. The 28-year-old Campbell continued his sharp play in the third as Anaheim started to push.
Toronto got a power play looking to add to its lead in the third, but Jones took advantage of a turnover and beat Campbell upstairs for his seventh at 8:34 to get Anaheim within one.
Anaheim tied it with 7:13 left in regulation when Henrique scored his 18th as he batted one out of the air on a power play.
Toronto took a 1-0 lead 4:36 into the game when Johnsson finished off a tick-tac-toe passing play with Marner and Matthews for his eighth. The goal was also the forward's second in 10 games after missing 15 with a leg injury.
Deslauriers tied it exactly six minutes later when he took a cross-ice pass from Fowler and one-timed a shot past Campbell.
F Kyle Clifford also made his debut for the Maple Leafs following Wednesday's trade with the Kings that brought him and Campbell to Toronto and sent forward Trevor Moore and two draft picks the other way.
Ducks: At Buffalo on Sunday.
Maple Leafs: At Montreal on Saturday night.
More AP NHL: www.apnews.com/NHL and www.twitter.com/AP-Sports