Canada’s juniors are heading home after falling to Finland 6-5 in a nail-biter of a match Saturday at the world junior hockey championship.

Canada, the defending tournament champion, grabbed the lead early in the game, but by the end of the first period, the two teams began trading goals that left fans on the edges of their seats.

In the end, three penalties in the final period cost Canada, allowing Finland to score the winning goal in the final six minutes of play with the help of a two-man advantage.

The opening goal came courtesy of Travis Konecny early in the first period. Minutes later, Dylan Strome added another for Canada. Just before the end of the first period, Finland’s Patrik Laine slid a shot through Mackenzie Blackwood's pads, to the cheers of the Helsinki home crowd.

As the second period got underway, Finland's Antti Kalapudas got a breakaway and tied it up with a wrist shot over Blackwood’s glove. Then Canada scored again, this time with a shot from Lawson Crouse.

That prompted Finland to pull goalie Veinie Vehvilainen in favour of Kaapo Kahkonen. Shortly after, Canada was handed a penalty for slashing, allowing Finland to get in back-to-back goals on the power play.

As the third period got underway, Canada's Mitch Marner tied it up on a power play, but just moments later, Finland's Sebastian Aho brought the tally to 5-4. Marner was able to score again in the final seconds of the power play, tying it up yet again.

But three penalties against Canada left Finland with a two-man advantage mid-way through the third, and the Finns were was able to take over the lead in the final five minutes of the period.

Canada's juniors struggled throughout this tournament, earning just one win, a shootout win and two losses in the preliminary round.

Head coach Dave Lowry told TSN after the game he thought the team improved throughout the tournament and said they were feeling good going into this game.

The loss is particularly disappointing for the team’s graduating players, Lowry said, given last year’s win. But he hopes the tournament will be a good learning experience for the team’s returning players.

“This is something that is extremely disappointing, but leaving knowing how hard this tournament is, they can share that information and that learning experience next year with their team,” Lowry said.

TSN’s Bob McKenzie says the Canadians dug themselves into a hole in this game with too many penalties and a lack of discipline, particularly in the final 10 minutes of play. But he says Finland was also a tough opponent.

“This Finnish team is loaded with skill,” McKenzie told CTV News Channel. “Some of the players on this team are going to go extremely high in the NHL draft and their best players were tremendous in this game.”

McKenzie noted that next year, the tournament will be held in Canada, which will put pressure on Canada’s juniors to perform better.

“I think that’s a positive pressure. Historically, Canada saves some of its best performances for those tournaments that are on home soil,” he said.

Finland will now move on to face Sweden in the semifinals.