Carey Price made 15 saves for the defending Olympic champion Canadians, who were stretched to the limit by Latvia goalie Kristers Gudlevskis.

The 21-year-old Tampa Bay Lightning prospect made 55 saves in a spectacular performance, nearly pulling one of the biggest upsets in hockey history largely by himself.

But Weber unleashed his peerless slap shot late in a power play, and Canada finally took the lead on its 54th shot against Gudlevskis.

Canada advanced to a semifinal meeting with the United States on Friday in a rematch of the gold-medal game in Vancouver four years ago.

One night after Latvia recorded its first Olympic victory in 12 years to reach its first quarterfinals, Buffalo Sabres coach Ted Nolan's team improbably tested the champs.

Lauris Darzins scored a breakaway goal in the first period for Latvia, which lost all three of its preliminary-round games before surprising Switzerland 3-1 on Tuesday to advance for the first time. The Baltic nation of 2 million people has been in the last four Olympic fields after a 66-year absence, but hadn't won a game since 2002.

With just one current NHL player, Buffalo's Zemgus Girgensons, and 41-year-old captain Sandis Ozolinsh leading the way, Latvia nearly did even better than fellow underdog Slovenia, which also reached the quarterfinals in Sochi before losing to Sweden.

Gudlevskis, who has mostly played for Syracuse in the AHL this season, mostly stymied the powerful Canadian offense with his scrambling, alert style.

Patrick Sharp scored in the first period for the Canadians, who cruised unbeaten through the preliminary round with three victories. Canada also lost forward John Tavares to injury in the second period.

Canada, which has won two of the last three Olympic tournaments, is the first defending Olympic champion to return to the semifinals since the current Olympic format was introduced in 1992. Nobody has won back-to-back gold medals in Olympic hockey since the Soviet Union in 1984 and 1988, although a unified team of former Soviet republics won the title in 1992 as well.

But a few hours after Russia's Olympic run ended at the Bolshoy Ice Dome with a quarterfinal loss to Finland, Canada created some eerie echoes of the Russians' downfall: Pedigreed forwards failing to score, defensemen making key mistakes and opposing goalies playing phenomenal hockey.

Canada had few major worries about its star-studded team during the first week in Sochi, although fellow semifinalist Finland took the Canadians to overtime.

Captain Sidney Crosby's goalless performance and a daily shuffling of the forward lines didn't suggest scoring trouble for such a potent lineup — particularly not against tiny Latvia.

Canada had quality scoring chances throughout the first period. Crosby missed on a breakaway a moment before linemate Chris Kunitz hit the crossbar on an open net, extending his Olympic funk.

Rick Nash finally engineered a goal with an exceptional play in front of Latvia's net, controlling the puck and circling to find Sharp for a wrist shot through Tavares' screen.

But just 2:04 later, Latvia's Arturs Kulda threaded a long pass through Canada's defense to Darzins, who skated in alone on a prone Price and tied the score with his third goal in two games.

Canada came agonizingly close to scoring on a goal-mouth scramble with 11:33 to play, but defenseman Kristaps Sotnieks reached over his prone goalie's arm to pull the puck off the goal line. The spectacular play seemingly could have resulted in a penalty shot, but the officials allowed the play to stand as called after video review.