Canada advanced to the semifinals for the seventh straight tournament. Devils center Travis Zajac
is a member of the Canadian squad that's seeking its third title in the last six world tourneys.
Team Canada held leads of 2-0 and 3-1. Latvia twice closed to within goal, but Matthew Lombardi's tally 3:07 into the final frame sealed the two-goal triumph.
Dany Heatley opened the game's scoring in the second period before Hamhuis made it 2-0 on the power play with six minutes left in the frame.
Latvia closed to 2-1 on Guntis Galvins' shorthanded tally, but Stamkos struck on the power with less than three minutes left in the second to put Canada on top by a pair.
Latvia's Herbert Vasiljevs made it 3-2 when he scored 1:27 into the third.
Canada will face Sweden on Friday after the United States and Russia faceoff in the day's first semifinal showdown. Devils goaltender Scott Clemmensen has backed up Robert Esche for Team USA.
Sweden received a goal and an assist from Mattias Weinhandl Thursday to top the Czech Republic, 3-1.
Devils defenseman Johnny Oduya has patrolled the blueline for his native Sweden, picking up two goals and an assist in three contests. Team Sweden is set for its ninth straight trip to the World semifinals.
Devils left wing Patrik Elias
finished the tournament with two goals in three games for the Czech Republic, which finished sixth.
Weinhandl opened the scoring on a power play early in the second, then set up Dick Tarnstrom's man-advantage goal later in the frame to build a 2-0 lead for Sweden.
Petr Cajanek's shorthanded tally for the Czech Republic trimmed Sweden's lead to 2-1, but Kenny Jonsson restored the two-goal edge with 2:14 left in regulation.