VANCOUVER -- Pavel Shen scored the go-ahead goal in the third period of a tightly fought game, and Russia held on to beat Canada 2-1 on Monday in the round-robin finale for both teams at the world junior hockey championship.

The win gave Russia top spot in Group A, while Canada finished in second place. Sweden finished the round-robin phase first in Group B.

Florida Panthers prospect Grigori Denisenko put up Russia's first goal.

Cody Glass scored for Canada and Owen Tippett registered the assist.

Vancouver Canucks prospect Michael DiPietro stopped 29-of-31 for the Canadians (3-1-0-0).

Russia (4-0-0-0) got 30 saves from Pyotr Kochetkov.

Shen put Russia up 11:00 into the third, skating around Canada's Markus Phillips and tucking the puck in behind DiPietro. The goal gave Canada its first deficit of the tournament.

Shen, a Boston Bruins prospect, has three goals and an assist in the tournament.

Canada took home gold at the world juniors last year while the Russians finished fifth. It was the first time since 2010 that Russia went home without a medal.

Canada was first on the score board 2:20 into the game.

Glass poked the puck away from a Russian defenceman and got off a shot that went over Kochetkov's pad.

The Vegas Golden Knights prospect has two goals and four assists in the tournament.

Russia responded with a power-play goal after Canada's Morgan Frost was called for checking from behind.

Vitali Kravtsov sliced a cross-ice pass to Grigori Denisenko in the face-off circle and the left-winger fired through a sliver of space between DiPietro and his goal post.

Tying the game seemed to ignite the Russians, who put heavy pressure on the Canadians, keeping the puck in the attacking zone.

The first period's physical play resulted in a flurry of penalties, including some that the crowd of 17,556 took issue with.

Russian captain Klim Kostin was called for cross-checking Maxime Comtois 13:10 into the frame, but Comtois was also handed a penalty for embellishment after he fell to the ice.

Chants of "ref you suck" echoed through the crowd as Canada's captain skated to the box holding his arm.

They vocalized their displeasure once again when Comtois was clocked for roughing with a minute-and-a-half to go in the first period.

Canada got its first man advantage midway through the second frame after Kravtsov was called for hooking.

Canada's power play saw some early chances, including one where the puck squeaked in behind Kochetkov before a defender swatted it out of harm's way.

But both netminders remained perfect throughout the second period.

DiPietro went into Monday's game having allowed a single goal at the juniors and boasting a .974 save percentage.

All 10 teams in the tournament will have New Year's Day off before games resume on Wednesday.

Russia will face Slovakia in the quarterfinals. Canada will play the loser of Monday's late game between Finland and the U.S.