DENVER — It wasn’t the overtime goal that gave the Colorado Avalanche a 5-4 victory over the Sharks that troubled goalie Evgeni Nabokov.

No, the problem was the four goals before that as Joe Thornton’s return to the lineup after missing three games turned into a roller-coaster ride on ice:

San Jose goes up by two, Colorado gets the next four, San Jose claws its way back and forces overtime, Colorado ends it when Avalanche defenseman John-Michael Liles cruises into the slot and deflects a shot from the point past Nabokov.

“He looped around the back and it was a good play,” Nabokov said of Liles. “If teams score goals like this, we can live with that. But when we give them the momentum, it’s not acceptable.”

By gaining only one point, the Sharks saw their lead over Chicago at the top of the Western Conference shrink to two points. Colorado is clinging to the conference’s final playoff spot, though the Avalanche weren’t playing desperate hockey at the start of the game.

A wrist shot by Dan Boyle caromed directly to Douglas Murray off an Avalanche defender’s skate and Murray’s 61-foot slap shot beat Colorado goalie Craig Anderson at 8:01 of the first period. Fifty-six seconds later, the Sharks took a 2-0 lead when Jamie McGinn snapped off a 27-foot shot that also eluded Anderson.

At that point, the Avalanche ratcheted things up, and miscues by the Sharks helped the Colorado cause.

Marc-Edouard Vlasic whiffed on a shot from the blue line and the puck ended up on the stick of Avalanche defenseman Kyle Quincey as he exited the penalty box. He scored and the lead was down to 2-1 by the end of the first period.

“We make a play that we probably shouldn’t make,” Sharks coach Todd McLellan said, “and we fan on a shot that we shouldn’t fan on.”

In the second period, two goals by Avalanche center Peter Mueller finished off odd-man rushes as the Sharks were caught out of position and Nabokov wasn’t able to come to the rescue.

Twenty seconds into the third, San Jose was short-handed when Rob Blake tried to carry the puck behind his net, only to lose it to Avalanche veteran Milan Hejduk who found Peter Stastny just outside the crease for a quick backhand.

“Their pressure played a big part in those goals,” McLellan said, “but also our misread and mishandling of the puck played into it.”

Once Colorado had the 4-2 lead, the Sharks did fight back. Patrick Marleau took a feed from Dany Heatley for a one-timer from the slot that beat netminder Craig Anderson at 8:13 of the final period. And Joe Pavelski pounced on a rebound of a shot by Heatley at 14:41 to tie things up.

The Sharks played the first two minutes of the overtime short-handed, but the momentum from a successful penalty kill never materialized as Liles won the game at 2:59.

Thornton, out since March 27 with a lower body injury, earned assists on the first and third San Jose goals. On a familiar line with Heatley and Marleau, Thornton played 19:30 and was credited with two shots.

Notes: The Sharks have landed one of the top college free agents in this year’s market with the signing of Princeton power forward Cam Macintyre. The official announcement is expected shortly, but a source inside the organization has acknowledged that an earlier report saying Macintyre chose the Sharks from several teams courting him are accurate. Macintyre is a 24, having played two seasons in the British Columbia Hockey League before four at Princeton. At 6-foot-1, 220 pounds, the thinking is he could be NHL ready or close to it, though he’ll have to prove himself at training camp next September. … Despite struggling at times on special teams over the past month, the Sharks have the distinction of being the only NHL team with both its power play and penalty kill in the top five.