The Wild weren't credited with all the offense, but they created every goal.

An unsuccessful clear, turnover and intercepted pass sparked the otherwise sleepy Sharks, handouts by the Wild that required a Kirill Kaprizov hat trick to outscore their mistakes and overcome second-to-last San Jose 4-3 on Sunday at Xcel Energy Center and snap their three-game losing streak.

"Sometimes those can be deflating if you feel like you're in control of things, but then all of a sudden there's a breakdown or there's a bounce and that winds up in the back of the net," coach John Hynes said. "So it was a hard-fought effort."

Kaprizov's third goal with 3 minutes, 59 seconds remaining completed the Wild's comeback and avoided an upset by the Sharks, who capitalized on back-to-back shots in the second to claim a 2-0 lead before moving ahead 3-2.

After also delivering the equalizer earlier in the third period, Kaprizov buried a puck pried away from San Jose by Matt Boldy and then nudged into a shooting lane by Joel Eriksson Ek. The goal was Kaprizov's team-leading 29th and the fifth hat trick of his career.

"Good passes from guys," Kaprizov said.

Now up to 300 NHL points, Kaprizov is the quickest Wild player to reach that plateau and the fifth-fastest among active NHLers.

"He's double-shifting sometimes. You can't even notice," Frederick Gaudreau said. "He doesn't seem tired. He does everything."

The Wild had extra ice time to dole out because they played down a forward.

Mats Zuccarello was at the arena pregame but was a late scratch due to personal reasons, a situation Hynes described as "all good with Zucc." Marcus Johansson also didn't suit up due to a lower-body injury suffered on Saturday in St. Louis.

But the Wild did get Gaudreau back after he missed the 3-1 loss to the Blues with a lingering upper-body injury he re-aggravated last Thursday at Nashville.

"It's hockey," said Gaudreau, who had a key role in the Wild's rally after former Wild players had a field day with Wild miscues: Mikael Granlund gobbled up a failed clear by Brock Faber before converting on the power play 1:41 into the second period. Then at 4:56, Nico Sturm polished off a shorthanded 2-on-1 after a Boldy giveaway.

But 50 seconds later and before that power play expired, Gaudreau nixed his 23-game goalless drought.

"We knew it was not going to be easy coming in tonight," Gaudreau said. "That's why when they took the lead we didn't panic. We just kept focusing on playing the right way, and I think we did a good job at that, and I think that allowed us to stay in the game."

By 7:01, the Wild caught up to San Jose when Mason Shaw set up a Kaprizov breakaway; the assist was Shaw's first point in just his second game with the Wild since healing a fourth ACL tear.

Soon after, the Wild had a four-minute power play but blanked on the opportunity to finish 1-for-3; the Sharks were 1-for-2.

Not taking advantage stung the Wild, because only 23 seconds into the third period Anthony Duclair pounced on a Faber turnover to give San Jose a 3-2 edge. All three Sharks goals vs. Wild goalie Filip Gustavsson (12 saves) were unassisted.

NHL standings

BOXSCORE: Wild 4, San Jose 3

"Obviously some mistakes cost us," Faber said. "But I thought for the most part we dominated the game."

Kaprizov did.

His second goal, at 2:38 of the third, was a scorching one-timer against one-time Wild goalie Kaapo Kahkonen (28 saves) that opened the door for his third hat trick this year, which tied the team's single-season record and kept the Wild eight points back of a playoff spot.

"All those players that are at his level in this league, you just wish you had that talent yourself," Gustavsson said. "I hope everyone can enjoy watching those players. That's what I'm doing."