Talk about a frantic finish.

The Sharks carried a one-goal lead into the final two minutes Monday night against the Colorado Avalanche, fell behind with 99 seconds left, got the goal they needed to force overtime from Joe Pavelski with 19.6 ticks on the clock and then left the SAP Center with a 5-4 shootout victory.

Whew.

"Crazy ending, and I'm sure coaches don't like to see that too often," said Brent Burns, whose second-period goal helped the Sharks build a 3-2 lead. "We got angry a little bit, but as a group I think we're pretty confident. It was just a matter of who was going to step up and get that next goal."

Pavelski's goal guaranteed one point for the night, and shootout tallies by Logan Couture and Patrick Marleau while goalie Antti Niemi stopped Nathan MacKinnon and Matt Duchene earned the second.

"Definitely wasn't ideal," said Sharks center Joe Thornton, who picked up three assists. "It would have been nice to grab two and not give them any, but that's the way it works sometimes."

The Sharks carried a 3-2 lead into the game's final two minutes on the even-strength goal by Burns and power-play blasts by Jason Demers and Matt Irwin, while Colorado got its scoring from MacKinnon and Gabriel Landeskog.

But San Jose fell behind with when Avalanche defenseman Erik Johnson scored at 18:09 with Colorado goalie Semyon Varlamov on the bench in favor of an extra attacker and former Shark Jamie McGinn deflected a shot over Niemi's shoulder 12 seconds later.

The fact it was Pavelski who bailed out his team only continued his current hot streak, as the goal was his sixth in the last seven games.

"Pav has been a real clutch player over the past two weeks for us," coach Todd McLellan said. "He's kind of the go-to-guy right now, he seems to be getting it done. We're happy for him and for us."

The teams traded power-play goals midway through the first period with MacKinnon giving the Avalanche a 1-0 lead at 11:05 and Demers getting his second goal of the season 48 hours after his first by blasting a shot that beat Varlamov at 13:59.

San Jose was applying pressure late in the period, but it was Colorado that took a 2-1 lead with 48.9 seconds left when the Sharks left Landeskog unchecked as he skated into the slot.

The Sharks, however, dominated the Avalanche in the second period, outshooting Colorado 21-5 and getting two goals for the effort.