EDMONTON — Canada is feeling a lot more battle-tested heading into the playoff portion of the Hlinka Gretzky Cup.

Josh Williams and Alexis Lafreniere each had a goal and an assist as Canada narrowly defeated Sweden 4-3 to close out the round robin portion of the under-18 hockey tournament on Wednesday.

Canada finished first in its pool with a record of 3-0, while Sweden was 2-1.

"It was a really close game," Lafreniere said. "They worked very hard, but we stayed focused on our game plan and had a big goal at the end of the game. We have to stay focused on ourselves going forward."

Matthew Robertson and Bowen Byram also scored for Canada.

"Sweden gave us a really good challenge, but we just kept going," Robertson said. "We faced some adversity with some of the calls, but I think we went out there and played our game right to the finish."

Lucas Raymond, Alexander Holtz and Elmer Soderblom responded for Sweden.

The Canadians will face the United States in Friday's semifinals, while Sweden will be up against Russia.

"We were challenged and that is always a good thing, seeing as we got the win," Williams said. "The Americans are a good team and it is obviously a huge rivalry. It will be fun to be a part of and hopefully we can get the win at home and get to the final on Saturday."

Canada has won gold in nine of the last 10 of these U-18 tournaments.

Despite being outshot 9-1 to that point, Sweden struck first on the power play with six-and-a-half minutes to play in the first period when Raymond took a nice return pass from Holtz and deposited the puck into the net before Canadian goalie Nolan Maier (Saskatoon, WHL) could get across.

Canada evened things up two minutes later when Williams (Medicine Hat, WHL) drilled on one-timer off a feed from Ryan Suzuki (Barrie, OHL) past Swedish goaltender Jesper Wallstedt.

The shots after 20 minutes favoured Canada 12-2.

Sweden came out flying to start the second, but with seven minutes remaining in the second period, Lafreniere (Rimouski (QMJHL), the early first overall favourite for the 2020 draft, corralled a rebound off the boards and made it 2-1 for the home side.

The Swedes tied the game back up eight minutes into the third period after a Canadian giveaway led to Holtz picking the corner on a long shot.

Canada regained the lead with 6:51 remaining when defenceman Robertson (Edmonton, WHL) came in from the point and lifted it over Wallstedt with a delayed penalty upcoming.

Sweden pulled even once more with 4:16 to play in the third when Soderblom tipped a power play point shot into the net.

Canada once again took the lead with 2:26 remaining with a power-play goal, as Byram (Vancouver, WHL) responded with a tip of his own to give Canada the narrow victory.

In its previous round-robin games, Canada defeated Switzerland 10-0 and Slovakia 4-2.

Notes: It is the first year the tournament is being co-hosted by Edmonton, which will have it every second year, with the odd years taking place in the Czech Republic… In the 27 years these U-18 championships have been held, Canada has won gold 21 times and medalled in 24… Last year's Hlinka tournament produced 77 players who went on to go in the 2018 NHL Entry Draft, including seven of the top 10.