SOCHI, Russia -- Oskars Bartulis and Lauris Darzins scored in the first period, and Latvia reached the Olympic men's hockey quarterfinals for the first time with a 3-1 victory over Switzerland on Tuesday night.

Edgars Masalskis made 32 saves and Darzins added an empty-net goal in the surprising Latvians' first Olympic victory since 2002, when they returned to the games after a 66-year absence.

Latvia went winless in preliminary-round play in Sochi, losing 1-0 to the Swiss in its opener.

Latvia and its Canadian coach, Buffalo's Ted Nolan, advanced to face defending champion Canada in the quarterfinals on Wednesday night.

Martin Pluss scored and Jonas Hiller stopped 19 shots for the Swiss, who are out despite allowing just four goals in four games. Switzerland managed just three Olympic goals of its own.

Hiller hadn't allowed a goal in Sochi, posting two shutouts in the preliminary round, until Bartulis beat the Anaheim Ducks goalie through a screen 8:38 in.

Masalskis, the Latvians' four-time Olympian, was a 21-year-old backup goalie when Latvia got its previous Olympic victory over Austria in Salt Lake City. He was the difference against the Swiss, repeatedly shutting down their scoring chances in spectacular fashion.

Latvia has only one NHL player, Buffalo forward Zemgus Girgensons, along with 41-year-old defenceman Sandis Ozolinsh as its captain. But its team effort shut down a Swiss lineup with nine NHL players.

The result is a bitter disappointment for the Swiss, who won twice in the preliminary round while allowing just one goal in three games. They allowed that many again in a 2:41 span of the first period against Latvia.

Switzerland beat Latvia in both teams' Olympic debuts last week on a last-minute deflection goal by Simon Moser after both teams played cautiously throughout. Latvia demonstrated the rematch would be different just 8:38 in when Bartulis wired a long shot just inside the far post of Hiller, who was completely screened by two players in front.

Darzins then scored on a sharp-angled shot on the power play, and Switzerland faced its first two-goal deficit of the tournament.

Switzerland opened up its attack in the second period, but Masalskis was both solid and spectacular on a glove save against Andres Ambuhl. Hiller was equally sharp for Switzerland, turning away a handful of point-blank chances.

The Swiss finally connected for their third goal of the Olympics late in the second period, with Pluss converting a one-timer from Reto Suri.

Players on both teams' benches stood to watch much of the third period. Suri had an unobstructed chance with 2:12 left, but put it straight into Masalskis' midsection.