SAN JOSE, Calif. -- This may have been the most unusual of Nikolaj Ehlers' four career hat tricks.

It didn't make it any less satisfying.

Ehlers snapped a tie with 3:07 to go and then completed the three-goal night when he was credited with a score after getting pulled down with San Jose's net empty, sealing a 5-3 victory for the Winnipeg Jets on Thursday.

"The two first ones were almost empty-netters and the third one the puck doesn't even go into the net," Ehlers said. "But we got the two points. My line mates made some pretty great plays there. It still feels good."

Ehlers scored in the first period following a bad bounce off the boards that left Martin Jones out of position and then knocked in the game-winner after Blake Wheeler drew Jones out of the net on a wraparound. Ehlers took the pass in the slot and knocked it past Joe Pavelski for the goal.

The final score came after Pavelski brought him down with 1:00 remaining, leading to the automatic goal because the Sharks had pulled the goalie. It gave Ehlers 14 goals in his past 22 games, including a second hat trick after he recorded one Nov. 29 against Chicago.

"(Ehlers) has a knack to put the puck in the net," said Wheeler, who assisted on all three of Ehlers' goals. "Obviously an incredibly dynamic player. He's doing a good job of being patient, jumping in the holes at the right time and banging them in."

Mason Appleton got his first career goal and Dustin Byfuglien also scored to help the Jets win for the sixth time in seven games. Connor Hellebuyck made 41 saves.

Evander Kane had a goal and an assist against his former team and Joe Thornton moved into 10th place all-time in assists for the Sharks, who had won five in a row. Pavelski and Joonas Donskoi also scored, and Jones made 19 saves.

"This might have been our best game in the last six games and it was the one we lost," coach Peter DeBoer said. "We had a good effort -- some unfortunate bounces."

It was an action-packed first period that featured five goals, five power plays, a fight between Barclay Goodrow and Brendan Lemieux, and a handful of big saves.

After the teams traded penalties in the opening 40 seconds, the Jets struck first during 4-on-4 play when Byfuglien stripped Brent Burns near the blue line and skated in for the breakaway goal 51 seconds into the game.

But in a sign of what was to come, the Sharks answered just 45 seconds later when Thornton forced a turnover that led to an odd-man rush that Kane converted for his first goal in six games against his original team. Thornton's 1,040th assist tied Marcel Dionne for 10th place all-time.

San Jose then took the lead nine seconds after Tyler Myers was called for interference, with Kevin Labanc's shot from the circle hitting Pavelski's pants on the way into the net. Pavelski's 22nd goal in the 36th game of the season equaled his total from all of last season.

The Jets responded with two more goals in the next 2:17, starting with Ehlers' first of the night. Nic Petan then set up Appleton for his first career goal to make it 3-2, and that's where the game stood after Hellebuyck made a big save on Timo Meier and Burns hit the post on the power play in the final two minutes of the period.

The second wasn't quite as frenzied, although Jones did rob Ehlers late in the period before the Sharks tied it with 5.3 seconds left when Donskoi deflected a pass from Kane into the net.

"Tonight was a heavyweight game for us," said Sharks defenceman Erik Karlsson, who extended his point streak to seven games with an assist. "We wanted to this one. But unfortunately they came away with it. We expect to be one of the top teams. Today we showed it in bits and pieces."