COLOGNE, Germany (AP) " The United States came back three times to hand Russia its first defeat 5-3 and top Group A with its sixth straight win at the ice hockey world championship on Tuesday.
Kevin Hayes scored two goals in his second game at the tournament, and Anders Lee earned the match-winner as the U.S. outshot Russia by 35 to 19.
"A great win. We grew as a team today," forward Johnny Gaudreau said.
They head to the quarterfinals on Thursday, when the U.S. will play Finland, and Russia will meet the Czech Republic.
Two-time defending champion Canada will play Germany, and Sweden takes on Switzerland.
Group B leader Canada beat fourth-placed Finland 5-2, with center Mitch Marner scoring twice in Paris.
Co-host Germany wasted a 2-0 lead against Latvia before leveling right at the end to make it 3-3, forcing overtime and penalty shots in Cologne. The first two shots from each side were saved and, after Roberts Bukarts hit the post, Frederik Tiffels settled it for Germany.
The Canadians, Russians, and Americans have lost one game. Russia scored 35 goals, the Canadians 32, and the Americans 31.
Switzerland avoided Russia by defeating the Czech Republic 3-1 in Paris to clinch second spot in Group B.
Nick Bjugstad hit the post early on for the U.S. before Artyom Zub was penalized for high sticking, then Nikita Kucherov for slashing, but the Americans failed to make their pressure count.
Nikita Gusev scored on a breakaway with just the Russians' second shot at 12:29.
With five penalties in the first period, Russian indiscipline was bailed out by their defense, while the Americans were grateful to goaltender Jimmy Howard for a good save on another Russian breakaway.
The U.S. had 16 shots compared to Russia's three in the first period alone.
Kucherov was still off the ice when Hayes equalized at the start of the second on a power play, scoring from a narrow angle. It was Hayes' first goal since joining the U.S. following the New York Rangers' elimination from the NHL playoffs.
Russia captain Anton Belov scored minutes later after Sergei Plotnikov sent the puck back, but Dylan Larkin equalized on another Brock Nelson assist.
U.S. captain Connor Murphy was penalized for interference and Gusev claimed his second on the power play " on a counterattack when the understrength Americans were attacking " leading to an evident surge in Russian confidence.
But Hayes scored again to tie the game at 3 going into the third period.
Frayed tempers led to a punch-up in the third, before Yevgeni Kuznetsov was penalized for slashing.
This time, the U.S. capitalized. Jack Eichel sent a long pass to Gaudreau, who found Lee free to score from close range.
Another moment of indiscipline from Kuznetsov, this time for blatant interference, dented Russian hopes, though Howard had to make another big save to deny Artemi Panarin the equalizer on a breakaway.
Russia went for broke, but Nelson sealed it for the U.S. with an empty net goal with 22 seconds remaining.
After Marner's early goal for Canada, center Jani Lajunen equalized for Finland within 18 seconds. But less than one minute later Marner set up Colton Parayko for another laser beam slap shot from the defender.
Center Nate MacKinnon, Canada's leading scorer with 12 points, set up Marner for 3-1 later in the first period.
Brayden Point got a fortuitous fourth after the puck came back off the boards and fell just in front of goal. But defenseman Atte Ohtamaa kept Finland in with an outside chance heading into the third period.
The suspense lasted precisely 34 seconds as Finland gave the puck away and center Matt Duchene peeled away to score.
It was a nail-biter in Cologne, where Germany equalized with 33 seconds to go through center Felix Schutz.
Germany broke through with two quick goals midway through the second period with left winger David Wolf netting and veteran defenseman Dennis Seidenberg scoring 27 seconds later.
But Latvia forward Gunars Skvorcovs replied late in the second period; Janis Sprukts equalized midway through the third, and center Andris Dzerins scored a power-play goal with four minutes left.
Earlier, Sweden defeated Slovakia 4-2 to finish third in Group A and Belarus defeated Norway 4-3 in Group B.