Mitch Marner scored with less than four minutes to go to cap the scoring in a wild third period, and Canada edged Sweden 7-6 Wednesday in its last exhibition match before the world junior hockey championship in Finland.

Canada led 5-1 heading into the third, before Sweden lit up Canada goaltender Mason McDonald with five goals over the final 20 minutes.

Marcus Pettersson's second goal of the period at 15:26 tied the game at 6-6 before Marner's goal salvaged the win for Canada.

McDonald recovered to make some big saves over the final minutes with Sweden pressing for the tying goal.

Vancouver Canucks forward Jake Virtanen had two goals for the Canadians, with Dylan Strome, Mitchell Stephens, Haydn Fleury and Brendan Perlini also scoring.

Oskar Lindblom, Jacob Larsson, Axel Holmstrom and Adrian Kempe had Sweden's other goals.

Canada plays its first tournament game Saturday against the United States at 1 p.m. ET.