Patrick Marleau has had a lot of success against the Edmonton Oilers this season.

The Sharks' assistant team captain found another way to keep the good times rolling.

In the process, he just might have salvaged San Jose's hopes of catching Anaheim in the chase for the top spot in the Pacific Division.

Marleau scored a tiebreaking goal with 7:29 left in the third period to lift the Sharks to a 5-4 win over the visiting Edmonton Oilers on Tuesday night after San Jose had squandered a two-goal lead.

"I think [Pavelski] actually kicked it over to me in front," said Marleau after notching his 32nd goal of the season. "It was good. I was just able to get it in the back."

It was a much-needed win for the Sharks, who came into their final homestand of the season after falling out of first place in the division following back-to-back losses to Winnipeg and Colorado.

San Jose has already locked up a playoff spot, but is trying to avoid a first-round matchup against the Los Angeles Kings.

The Sharks had blown a 3-1 lead and were 0 for 5 on power plays before Marleau rocketed a shot past Edmonton goalie Ben Scrivens after Scrivens had deflected a one-timer by San Jose's Brent Burns.

Dan Boyle, Andrew Desjardins and Tommy Wingels also scored for the Sharks, who moved within one point of first-place Anaheim in the Pacific Division.

"I still think our team looks lethargic," San Jose coach Todd McLellan said. "We're there but we're not really getting it done. Right now we're still in a fight, which I think is good for us, to stay focused and have that battling mentality."

The Sharks still face an uphill climb. Four of their final five games are against teams in playoff contention.

Ryan Nugent-Hopkins had two goals and two assists for Edmonton, which lost for the fourth time in five meetings between the teams this season.

"We knew coming in we couldn't take penalties but for whatever reason, a couple that we probably shouldn't have taken and it comes back to bite us," Nugent-Hopkins said. "I thought we showed a lot of push-back. The way we climbed back in the game was really big for us. We just have to take some momentum from it."

This one nearly got away after San Jose built an early lead.

Edmonton scored two goals in a 38-second span in the second period to tie the game, then took the lead when Nugent-Hopkins scored his second goal of the game 6:16 into the third.

After Burns' tied it off an assist from Joe Thornton, Marleau sent the crowd at SAP Pavilion home happy with his game-winner.

Antti Niemi made 25 saves for San Jose.

Taylor Hall scored the other goal for Edmonton. Nugent-Hopkins nearly had a hat trick after being credited with a goal in the second, but it was later awarded to Jordan Eberle.

Scrivens set an NHL record for most saves in a regular-season shutout when the two teams played on Jan. 29, but wasn't nearly as sharp this time.

Neither was Niemi.

Desjardins' third goal of the season 3:11 into the first put the Sharks up 1-0. Desjardins scored off a deflection in front of the net after Scrivens stopped a shot by Tyler Kennedy.

Hall tied it on a power-play goal for Edmonton after a roughing call against Boyle.

Boyle, penalized twice in the first period, made up for it with another point-blank shot in front of the net that made it 2-1.

After San Jose's power-play unit missed a chance to pad the lead early in the second, Wingels tapped the puck past Scrivens for an even-strength goal that gave the Sharks a 3-1 lead.

Edmonton tied it with two goals in 38 seconds.

Nugent-Hopkins, who had an assist on Hall's goal, scored to cut the gap to 3-2 before Eberle's game-tying shot. Nugent-Hopkins was originally credited with the goal after the play was reviewed and upheld, but a scoring change later awarded the shot to Eberle.

Nugent-Hopkins put the Oilers ahead when he scored 6:16 into the third before Burns tied it for the Sharks midway through the final period.

"We're happy with the two [points], but we've got to tighten up for the post-season," Thornton said. "We've got five games here to do that."