VANCOUVER, British Columbia — While the Boston Bruins beelined across the ice to mob him at the buzzer, Tim Thomas tapped both goalposts, sank to his knees and rubbed the ice in front of his empty goal.

Thomas drew a virtual line in his crease throughout these crazy, contentious Stanley Cup finals, and just wouldn’t allow the Vancouver Canucks to cross it whenever it really mattered.

After 39 years without a championship, the Bruins ripped the Cup — and thousands of hearts — out of a Canadian city that had waited four decades for one sip.

Thomas was just too good, and the Bruins are the NHL’s best.

The Cup is headed back to the Hub of Hockey.

Thomas made 37 saves in the second shutout of his landmark finals performance, Patrice Bergeron and rookie Brad Marchand scored two goals apiece, and the Bruins beat the Canucks 4-0 on Wednesday night to win their first championship since 1972.

“I think I went even further than I thought,” Thomas said. “I never envisioned three Game 7s in one playoff season and still being able to come out on top.”

The Bruins leaped over the boards and headed straight for Thomas at the final buzzer, mobbing the goalie who carried them through long stretches of this postseason.

The Bruins are the first team to win a Game 7 three times in the same postseason, with Thomas posting shutouts in the decisive game of the Eastern Conference finals and the Stanley Cup finals.

After the game, Thomas was named the winner of the Conn Smythe Trophy as the most valuable player of the playoffs.

Zdeno Chara, the team captain, nearly slipped when he skated away from Commissioner Gary Bettman with the Stanley Cup. And the oversized trophy eventually got a lift from Nathan Horton, the injured Boston forward whose Game 3 concussion on a late hit by the Canucks irrevocably swung the series’ momentum to Boston.

Before Game 7, Horton worked to give the Bruins a home-ice advantage, pouring a bottle of Boston water onto the ice in front of the team bench 90 minutes before warm-ups.

“I was just trying to get some Garden ice here and make it our ice,” Horton said.

But it was mostly Thomas, who limited the Canucks to eight goals in seven spectacular games in the finals, shutting out Vancouver in two of the last four. Boston dropped the first two games in Vancouver but became just the third team since 1966 to overcome that deficit.

“We got the first goal and we knew that would be important coming here,” said the 43-year-old Mark Recchi, who plans to retire after winning the Stanley Cup with his third franchise. “If they got any chances, Timmy was there, and it was just scary how good he was.

“What a feeling this is. What a great group of guys. No matter what happened tonight, this is one of the best groups of guys I’ve played with.”

Bergeron quieted the crowd with the first goal, scoring the eventual winner in the first period. He added a short-handed goal in the second to keep the Cup away from the Canucks, who have never won it in nearly 41 years of existence.

Canucks goalie Roberto Luongo again failed to match Thomas’ brilliance, giving up 18 goals in the last five games of the finals.

Luongo capped a brutally inconsistent series by allowing Bergeron’s crushing short-handed goal to slip underneath him late in the second period.

“Their goaltender was real tough to beat,” Vancouver Coach Alain Vigneault said. “The way they played in front of him was real tough to beat. We had some Grade A chances and we were unable to score.”

Game 7 was another heartbreak for the Canucks and their stunned fans, who stayed by the thousands just to get a glimpse of the trophy.

Mark Messier and the New York Rangers won Game 7 in Vancouver’s last finals appearance in 1994.

This time, Thomas silenced the NHL’s highest-scoring team, erased nearly four decades of Bruins playoff blunders, and crushed an entire Canadian city desperate to take the Stanley Cup across town to Stanley Park.

“Anybody in our situation right now would feel real disappointed, whether you’re the favorite or not,” Vigneault said. “We battled real hard. We gave it our best shot. This one game, they were the better team. It’s that simple.”