RIGA, Latvia -- Canada has advanced to the quarterfinals at the world hockey championship, an outcome that looked highly unlikely after a dreadful 0-3 start.
The Canadians needed to wait until Tuesday's late games ended to find out of they made it out of the preliminary round, but they got the help they needed when Germany defeated Latvia 2-1 in regulation. That result locked Canada into fourth place in Group B with 10 points.
Earlier Tuesday, Canada fell 3-2 in a shootout to 2019 champion Finland in its final preliminary round game. Canada missed an opportunity to clinch a quarterfinal berth with a win, but the point from the overtime loss kept Canada's hopes alive.
"We have a very young team. I think we're the youngest in the tournament but it's a great opportunity for the kids to come over here," Canada head coach Gerard Gallant said after the game. "I think a lot of the guys come over here for the first time and say 'The players here are better than we think they are,' and they work really hard.
"It has been an outstanding tournament, we got off to a tough start but have played good hockey lately. I hope we get an opportunity to get in the crossover and continue what we're doing, but the last four games we have played really well."
The United States finished first in Group B with 18 points, followed by Finland (17) and Germany (12).
Kazakhstan also had 10 points, but Canada owned the head-to-head tiebreaker between the teams. Latvia finished sixth with nine points.
Canada will face Russia, which won Group A with 17 points, in the quarterfinals. Switzerland (15 points), the Czech Republic (13) and Slovakia (12) also advanced out of Group A. Perennial powerhouse Sweden was left out after finishing fifth with 10 points.
The quarterfinals are scheduled for Thursday.
Canada was in danger of missing the playoffs at a world championship or Olympics for the first time after starting the tournament 0-3 with losses to Latvia, the United States and Germany.
But Canada found its groove in a 4-2 over Norway, with Calgary Flames forward Andrew Mangiapane joining the team to form an effective top line with captain Adam Henrique and Ottawa Senators forward Connor Brown.
Canada followed with a crucial 4-2 win over Kazakhstan and a 7-1 romp over winless Italy to give it a chance to move on heading into Tuesday's showdown with Finland.
In Tuesday's game, Maxime Comtois and Brandon Pirri scored for Canada while Arttu Ruotsalainen scored two goals for Finland, including the tying goal with four minutes left.
Ruotsalainen was one of three players to beat Canadian goalie Darcy Kuemper in the shootout. Canada put two shots past Finnish netminder Jussi Olkinuora.
"I thought we played well today and there were stretches where we were taking the game to them," Henrique said. "(Finland is) a good team, they responded well early in the second period, but I thought we stuck to our game."
Brown tied for the scoring lead in the preliminary round with 10 points (two goals eight assists) in seven games. Henrique was tied for third with nine points (four goals, five assists) while Mangiapane had four goals and four assists in just four games.
In other results Tuesday, it was: Switzerland 6 Britain 3; Czech Republic 7 Slovakia 3; U.S. 4 Italy 2; and Russia 6 Belarus 0.