BUFFALO, N.Y. -- The United States made another late push to keep its momentum going into the medal round of the world junior hockey championship.
Adam Fox scored with 1:37 left in the third period to give the U.S. a 5-4 victory over Finland on Sunday in the Americans' final preliminary-round game.
The defending champion Americans (3-1) finished second behind Canada in the Group B standings and will face Russia in the quarterfinals Tuesday.
Fox also had two assists, Joey Anderson scored twice, Casey Mittelstadt had a goal and two assists, Brady Tkachuk added three assists, and Joseph Woll stopped 20 shots.
"We are really confident and we believe in our group," Tkachuk said. "It's a new tournament now, it starts on Tuesday, and we are excited."
Canada (3-1) secured the top seed in Group A because of the point earned in its 4-3 shootout loss to the U.S. at the Buffalo Bills' New Era Field on Friday. Canada will meet Switzerland in the quarterfinals.
Sweden (4-0) is the top seed in Group B and will play Slovakia in the quarterfinals. Oskar Steen scored the deciding goal in Sweden's 4-3 shootout victory over Russia on Sunday night.
Earlier Sunday, Kristian Reichel scored twice in the Czech Republic's 6-3 victory over Switzerland.
The Czech Republic (3-1) moved into second place in Group A and will face Finland in the quarterfinals.
Tuesday's quarterfinal game between the Americans and Russians will be a rematch of last year's semifinal, which the U.S. won 4-3 in a shootout for its first victory over Russia in a medal-round game at the world juniors. Russia eliminated the U.S. in the quarterfinals in 2014 and 2015.
The U.S. came back from two goals down to defeat Canada in a shootout in last year's gold-medal game and repeated the feat in Friday's outdoor game that set a tournament attendance record of 44,592.
In Sunday's matchup between the American and Finnish teams that have won four of the last five gold medals, Finland came back from a three-goal deficit to tie it before Fox scored the winner on a partial breakaway after a lead pass from Mittelstadt.
Kristian Vesalainen and Joona Koppanen scored 66 seconds apart for Finland midway through the third period to tie it.
"There was no doubt on the bench that we were coming back and getting the next one," said Anderson, the U.S. captain.
Trent Frederic and Mittelstadt scored in the first 15 minutes, and Anderson's goal on a 5-on-3 power gave the U.S. a 3-0 early in the second period. Aapeli Rasanen and Eeli Tolvanen got Finland within a goal before Anderson scored again on a power play in the closing minutes of the second.
"We came back the other day and today felt like a comeback," Frederic said. "It shows we can turn it on when we have to, but now we have to turn it on all game in the quarters."
Ukko-Pekka Luukkonen made 32 saves for Finland.
Mittelstadt, the University of Minnesota freshman and most recent first-round draft pick of the Buffalo Sabres, is the tournament's leading scorer with nine points (four goals, five assists). Mittelstadt assisted on all three regulation goals in the comeback victory over Canada.
Tkachuk, a Boston University freshman and one of the top prospects eligible for the 2018 NHL draft, set up Mittelstadt's goal with a deft pass in front of the net. Tkachuk scored the tying goal and shootout winner against Canada.
In another preliminary-round game, Milos Roman scored two goals as Slovaki defeated Denmark 5-1 to finish fourth in Group A. Slovakia handed the U.S. its only loss in the preliminary round.
Timothy Liljegren had a goal and an assist in Sweden's win. Lias Andersson and Glenn Gustafson also scored.
Dimitri Sokolov, Klim Kostin and Alexei Polodyan had goals for Russia. Vladislav Sukhachyov stopped 39 shots.
In the Czechs' victory, Martin Necas, Daniel Kurovsky and Martin Kaut each had a goal and an assist. Jakub Lauko also scored and Libor Hajek had two assists.
Ken Jager, Dario Rohrbach and Elia Riva had goals for Switzerland (1-3), which finished fourth in Group B. The Swiss have never beaten their quarterfinal opponent Canada in 21 world juniors meetings.
Denmark and Belarus will play a relegation game on Tuesday.