Antti Pihlstrom's marker with 1:14 remaining in overtime lifted Finland to a 3-2 decision over plucky Latvia on Tuesday and gave one of the two host nations of this tournament the first- place slot in Group H.
Mikael Granlund and Sakari Salminen also lit the lamp and Tuukka Mantyla added two assists for the Finns, who vaulted over the Americans and Russians to take the top spot and will take on Slovakia in a Thursday quarterfinal.
Antti Raanta stopped 18 shots for Finland to outduel counterpart Kristers Gudlevskis, who made 26 saves in defeat. Gints Meija and Roberts Jekimovs tallied for the Latvians.
Slovakia needed a win in its round-robin finale to reach the quarterfinals, and did just that with a convincing 4-1 victory over the United States earlier in the day at Hartwall.
The Americans would have claimed first place in Group H with a win, but fell behind 3-0 and never recovered.
Rostislav Stana finished with 20 saves for Slovakia, which finished fourth in the group.
Ben Bishop stopped 22 shots for the Americans, who take on Russia in the quarters.
Switzerland, meanwhile, completed an undefeated round-robin slate with a 4-1 win over Belarus and wrapped up the top spot in Group S, two points ahead of Canada.
The Swiss will play the Czech Republic in the quarterfinals at Stockholm after the Czechs earned the final spot in the round of eight with a 7-0 rout of Norway on Tuesday. Canada and Sweden will meet in the other Group S quarterfinal.
The Swedes finished round-robin play by dispatching Denmark, 4-2.