TORONTO (AP) -- Kasperi Kapanen was looking to get off the ice. Instead, he wound up scoring the game-winning goal in overtime.
Kapanen scored his second goal of the game at 1:53 of overtime and the Toronto Maple Leafs defeated the Detroit Red Wings 5-4 on Sunday night.
Kapanen's winner squeezed through the pads of former Leafs goalie Jonathan Bernier and just got over the goal line.
"I was huffing and puffing," said Kapanen, who has 14 goals this season after scoring just eight in his first 55 NHL games. "Lucky enough it went in."
Morgan Rielly and John Tavares each had a goal and an assist, and Frederik Gauthier also for Toronto, which extended its winning streak to four games.
Garret Sparks made 26 saves for the Leafs.
"We had to fight our way back," Tavares said. "Just competing right to the end."
Frans Nielsen, Filip Hronek, Michael Rasmussen and Christoffer Ehn scored for Detroit. Bernier stopped 19 shots for the Red Wings.
With Toronto down 4-3, Tavares knotted things up with 7.6 seconds left in regulation when he tipped a shot from the point by Jake Gardiner past Bernier for his 24th of the season with Sparks on the bench for the extra attacker.
"I saw the puck from the point, but there's no chance I can react to that," Bernier said of the equalizer. He said it was a great tip.
Tavares then nearly won it a minute into overtime, but he shot high over Bernier's net from close range before Kapanen won it.
Tied 3-3 through 40 minutes, Nazem Kadri had a chance right at the end of a Toronto power play in the third period, but his try to redirect a pass from William Nylander hit the crossbar.
Nielsen eventually snapped the deadlock with under eight minutes to go when he buried a rebound past Sparks, who was making his first start for Toronto since allowing five goals on 32 shots in Detroit's 5-4 overtime victory at Scotiabank Arena on Dec. 6.
Detroit led 2-1 after the first and stretched that advantage at 9:53 of the second when Ehn took a long pass from Wade Megan before fighting off both Travis Dermott and Justin Holl and chipping a backhand over Sparks for his first NHL goal in his 22nd game.
A sluggish Toronto team got some life thanks to its fourth line 2:59 later. Gauthier scored his first goal of the season off a pass from Par Lindholm. Trevor Moore, called up from the Toronto Marlies of the AHL after winger Tyler Ennis broke his ankle on Saturday, picked up the second assist for his first NHL point in his debut.
"A lot of nerves, but it was fun," the 23-year-old Moore said. "I just tried to take everything in."
The Leafs, who came in having scored 18 goals during a three-game winning streak, then tied the game with six minutes left in the second. Tavares took a pass and drew the puck up between his own skates before whipping a feed to Rielly, who beat Bernier high for his 13th.
Rielly leads all NHL defenseman in goals and points (44). He now has three goals and eight assists during a five-game point streak.
The Leafs got their first power play late in the second, but Kadri hit the post on a tip of a shot from the point by Gardiner.
Toronto got off to a fast start as the new second line of Kapanan, Nylander and Auston Matthews connected 27 seconds into the first.
Bernier was there to stop the initial shot from Matthews, but Kapanen outmuscled Red Wings defenseman Trevor Daley and scored his 13th.
Detroit got that one back at 3:45.
The Red Wings pushed ahead with 41.8 seconds left in the period on a delayed penalty when Rasmussen tipped a shot from Dylan Larkin for his sixth goal of the season as Detroit outshot Toronto 14-3 in the opening 20 minutes.
"I like the resiliency when we need it," Leafs head coach Mike Babcock said. "I wish we didn't have to use it.
"(The season's) 82 games and when you look at it at the end, the teams that win lots win 3-2, they come back, they find ways to win. That's what good teams do. It's not perfect every night."
NOTES: Bernier played three seasons with the Leafs from 2013 to 2016. ... Detroit center Andreas Athanasiou (upper-body injury) missed his second straight game. ... Red Wings defenseman Trevor Daley played the 1,000th game of his NHL career.
Red Wings: Host Pittsburgh Penguins on Thursday.
Maple Leafs: At Columbus on Friday.