SAN JOSE -- The Sharks managed to keep a little suspense in the Pacific Division title race Tuesday night, but they needed a little soccer-style magic to come from behind against one of the NHL's bottom-feeders to do it.

San Jose ended a two-game losing streak, beating the Edmonton Oilers 5-4 on two goals midway through the third period by Brent Burns and Patrick Marleau after coughing up a two-goal lead earlier in the game.

The win closed the gap behind the Anaheim Ducks to one point, but the Sharks have now played two more games.

"You're happy with the two, but we've got to tighten up a lot before the postseason," said Sharks captain Joe Thornton, who had two assists. "We have five games to do that. We'll take the points, but we've got to play a lot better than that."

San Jose's other goals came off the sticks of Andrew Desjardins, Dan Boyle and Tommy Wingels, while Edmonton got a pair from Ryan Nugent-Hopkins and singles from Taylor Hall and Jordan Eberle.

The Sharks were trailing 4-3 when their comeback began on a play that saw Joe Pavelski kick the puck to Thornton, who then found Burns for a one-time from just outside the crease at 10:35 of the third.

"It was great," Thornton said of Pavelski's no-look pass off the skate. "I was just saying, we play soccer before the game, and a nice little play by Pav."

Less than two minutes later, the Sharks were just starting a power play that had been 0-for-5 when Burns only got a piece of his shot from the blue line, but the puck deflected to Marleau on the right side of the net, and he poked it into an all-but-open net.

"Yeah, coming down that back side looking for any scraps," he said of his urgency on the play.

The late goals avoided what could have been a disastrous loss to yet another team that will be on the golf course by mid-April. The Sharks had built a 3-1 lead early in the second period only to have the Oilers tie it on goals by Nugent-Hopkins and Eberle just 38 seconds apart.

"The intensity probably dropped a little bit," said Boyle, who scored a goal in his third consecutive contest after a 30-game drought. "We're up 3-1 against a team that's not in the playoffs. Sometimes you take your foot off the gas a little bit."

San Jose did stake itself to an early lead when the fourth line chipped in a goal by Desjardins at 3:11 of the first period as he potted the rebound of a shot by Tyler Kennedy. But the Oilers tied it up on a power-play goal by Hall a little more than eight minutes later.

Still, the Sharks seemed in control at 15:54 of the opening period when Thornton won a faceoff in the Edmonton zone, then found Boyle open for a shot that beat Oilers goalie Ben Scrivens high on the far corner.

The lead grew to 3-1 in the second period when, just as a power play ended, Wingels tucked the puck into the net at 2:45 after a shot from the point by Brad Stuart.

The Edmonton comeback followed and that all but overshadowed the win for Sharks coach Todd McLellan.

He had talked before the game about his team's lack of consistency -- "play real well for 15 minutes in a period and go to sleep for five" -- and agreed that was the case again Tuesday.

"It's a bittersweet win," McLellan said. "It was nice to see us come back and score five and the power play contributed. Those types of things are nice, but I'm going to leave the rink a little more frustrated than excited. I'm sure some of our players will leave that way, too."

He described his team as lethargic -- "not as much physically as mentally" -- and welcomed the week at home to try and get everything straightened out in the five final games of the regular season.

Thursday's game
Los Angeles (44-26-6) at Sharks (48-20-9), 7:30 p.m. NBCSN