SAN JOSE, Calif. (AP) — The San Jose Sharks seemed intent to go after Nazem Kadri right from the start. That didn’t bother the Toronto Maple Leafs a bit and they ended up with the win.

John Tavares opened the scoring just after a power-play for an early run at Kadri ended and Kasperi Kapanen had two goals, including a short-handed tally that broke a tie in the second period and sent the Maple Leafs to their fifth win in six games, 5-3 over the Sharks on Thursday night.

“I don’t know what was going on to be honest,” Kapanen said about Barclay Goodrow going after Kadri right off the opening faceoff.

“Nazzy loves that stuff. It got him into the game. I think that was a mistake by them. To go after Naz like that is not going to do anything to him. I think it’s the opposite. It’s going to get him going. I thought our line had a pretty good night tonight.”

The Sharks were still upset at Kadri for pulling out a chunk of Joe Thornton’s beard during a scrum last season in Toronto. Goodrow sought revenge early and the Sharks kept going after Kadri for most of the night.

“It seemed like they were pretty agitated to start, so I figured I’d just try to use that to my advantage,” Kadri said. “I think they might have been a little too worried about their own thing out there. We took care of business, and it was a good win for us.”

Frederik Andersen made 42 saves and assisted on Mitch Marner’s insurance goal with a pass to the opposite blue line late in the third period to seal Toronto’s eighth win in nine road games this season. Josh Leivo also scored for the Leafs.

Joe Pavelski scored his fourth goal in the past three games, and Kevin Labanc and Marc-Edouard-Vlasic also scored for the Sharks, who had their four-game home winning streak snapped.

Martin Jones made 29 saves but wasn’t able to stop enough of the several odd-man rushes the Leafs generated with their speed.

The Maple Leafs took the lead in the second thanks to a pair of odd-man rushes. Leivo tied the game early in the period when he converted a two-on-one off a pass from Tyler Ennis.

Then with the Sharks on the power-play midway through the second, Toronto took advantage of a turnover at the blue line by Pavelski to take the lead. Marner got the puck ahead to a streaking Kapanen, who went in all alone and beat Jones to make it 4-3.

“The frustrating part right is we haven’t played to our identity,” Pavelski said. “We do it for a few minutes and then we do this or that and suddenly there’s a breakaway, then another breakaway. We’re just hanging them out to dry with these odd-man rushes and chances. It happened again tonight. It can’t happen five times a night.”

The teams traded goals off fortunate bounces early with Tavares’ centering pass deflecting off Vlasic’s skate and into the net just after Goodrow got out of the box for his penalty against Kadri.

The Sharks tied it when Erik Karlsson’s dump-in bounced in front of the net instead of going around the boards. Andersen never saw it and Labanc knocked the loose puck into the open net.

Patrick Marleau then got his first point against San Jose after scoring 1,082 for the Sharks during his 19 years with them when he took advantage of a bad line change to find Kapanen on a two-on-one.

“It was pretty emotional,” Marleau said about his second game in San Jose since signing with Toronto. “Being on the other side for so many years and being on this side is a little different.”

But Pavelski tied it with a deflection off a pass from Brent Burns on a power play about a minute later and then set up Vlasic for his goal late in the period that made it 3-2.

NOTES: Maple Leafs F Auston Matthews (shoulder) skated in the morning but will miss his eighth straight game. ... Sharks F Tomas Hertl was scratched with a lower-body injury. ... Former Sharks goalie Evgeni Nabokov was honored before the game for getting inducted into the San Jose Sports Hall of Fame. His former teammate, Marleau, represented the Leafs in the ceremonial opening draw against Pavelski.