SAN JOSE -- Barclay Goodrow scored 18:19 into overtime, and the San Jose Sharks rallied with a four-goal, third-period power play in a 5-4 win against the Vegas Golden Knights in Game 7 of the Western Conference First Round at SAP Center on Tuesday.

San Jose won three games in a row, including Game 6 in the second overtime, to win the best-of-7 series, and will play the Colorado Avalanche in the second round.

Goodrow took a pass from Erik Karlsson and cut toward the net from the right wing to score from close range against Marc-Andre Fleury.

[WATCH: Golden Knights vs. Sharks Game 7 highlights | Complete series coverage]

"I saw Erik get the puck in the middle," Goodrow said. "I just got on the ice, so I saw [defenseman Brayden McNabb] was a little flat-footed. I thought maybe if I could skate, I could maybe get behind him. Obviously, Erik's a world-class player. He's able to make that play. I thought if I could get to the far side on Fleury I might have a chance."

Video: VGK@SJS, Gm7: Goodrow nets series-winner in OT

Jonathan Marchessault tied the game 4-4 for the Golden Knights with 47 seconds remaining in the third period after the Sharks rallied from down 3-0 earlier in the period to take the lead with four goals in 4:01 during Cody Eakin's major penalty for cross-checking Joe Pavelski.

"This one will sting," Vegas forward Max Pacioretty said. "We thought we played well enough to win this series. We know in the [Stanley Cup] Playoffs it comes down to a bounce or two, but this will be tough to digest for a while."

Logan Couture scored twice, and Tomas Hertl and Kevin Labanc each scored on the power play after Eakin's penalty at 9:13. Pavelski left the game with an undisclosed injury.

Labanc, who had three assists during the power play, gave San Jose a 4-3 lead with 6:19 remaining after Couture tied it 3-3 with 7:07 left with his second goal.

"That was the best game I've ever been a part of. Period," Sharks center Joe Thornton said. "Down 3-1. Down 3-0 with 10 (minutes) to go. It was just … That's an incredible series."

Video: VGK@SJS, Gm7: Sharks erupt for four goals late in 3rd

Hertl got San Jose to within 3-2 at 10:09 after Couture scored to make it 3-1 at 9:20.

"I think they saw a guy that they love and respect in some distress and wanted to do what they could to help the situation, which was try and get some goals and get us back in the game, and they did that," said Sharks coach Peter DeBoer, who did not have an update on Pavelski.

Eakin, William Karlsson and Pacioretty scored, and Fleury made 43 saves for the Golden Knights, who played in their first Game 7.

"Last year, we were in the Stanley Cup Final, and it was tough to lose," Vegas coach Gerard Gallant said. "Tonight was tougher than that, it really was, the way we lost."

Video: VGK@SJS, Gm7: Marchessault ties it up in final minute

Karlsson gave the Golden Knights a 1-0 lead at 10:10 of the first period, scoring on the rebound of a shot by Reilly Smith.

Eakin made it 2-0 at 10:00 of the second period when he scored with a deflection of a McNabb shot. The goal was upheld after it was reviewed to determine whether Eakin played the puck with a high stick.

Pacioretty made it 3-0 at 3:36 of the third with a wrist shot from the left face-off circle.

Martin Jones made 34 saves for the Sharks, including nine in overtime.

"That's the craziest game I've ever seen," DeBoer said. "I think they'll be talking about that one for a long time here."

Video: Dunkin' NHL Comebacks: San Jose stuns Vegas in Game 7

They said it

"San Jose came out and played well. [Marc-Andre] Fleury made some unbelievable saves in the first 15 minutes, and it was 3-0 for us. We were a little fortunate to be there, but you've seen what happened after that. It's a shame [the Cody Eakin major penalty] happened. We should be playing the next game." -- Golden Knights coach Gerard Gallant

"That's a once-in-a-lifetime game, I think. Knock on wood. I don't think my heart can take another one like that. That was up and down, and by the 10-minute mark of the overtime, there was just nothing left. ... What a game." -- Sharks forward Logan Couture

Video: #ThirstForTheCup: San Jose advances to Second Round

Need to know

The Sharks were 4-for-25 on the power play in Games 1-6 and 0-for-4 in Game 7 before scoring four times during Eakin's five-minute major. ... Erik Karlsson had two assists in Game 7 and nine in the series. The only defensemen with more assists in an NHL playoff series are Paul Coffey (11 for Edmonton Oilers in 1985 Campbell Conference Final) and Al MacInnis (11 for Calgary Flames in 1984 Smythe Division Final). ... Hertl and Couture each had six goals in the series. ... Fleury lost a Game 7 on the road for the first time. He was 3-0, all with the Pittsburgh Penguins.

Video: VGK@SJS, Gm7: Sharks, Golden Knights shake hands

What's next

Golden Knights: Season over

Sharks: Host Colorado Avalanche in Game 1 of Western Conference Second Round on Friday (TBA)

Video: Sharks rally, win epic Game 7 in overtime