A serious injury to Canadian captain Al Charron spoiled the Maple Leafs' night even as they handed Tonga an 24-7 defeat in Wollongong to ensure the Pacific Island nation finished bottom of Pool D.
Canada scored two tries to one, winger Sean Fauth replying in the second half to Inoke Afeaki's 17th-minute touchdown and reserve hooker Aaron Abrams driving over in the last minute.
Canadian fly-half Bob Ross kicked four penalties, while opposite number Pierre Hola hit just one conversion, and Ross' tactical kicking also ensured Tonga were often forced to attack from deep inside their own half.
The match took its unpleasant turn in the 69th minute when Charron copped an awful blow to the head from the shoulder of Hola and was stretchered off.
Referee Alain Rolland stopped play immediately because of the injury and medical personnel rushed to the aid of Charron, who is the oldest man in the tournament and likely to retire after the match.
It was an awful way for him to end his 75th match in a Canadian shirt and 25th as skipper.
Canada had failed to take advantage of the stiff breeze and a possession advantage in the first half, and could easily have been trailing at half-time.
Ross provided some excellent field possession with his thunderous right boot for Canada, but Tonga's bustling defence and some poor execution prevented the North Americans capitalising.
Canada claimed the early advantage scrum-half Morgan Williams showed good awareness to take a penalty quickly and, when Hola failed to retreat, Ross kicked the three points.
Hola missed a penalty from a handy position shortly afterwards, clearly affected by the wind, but Canada did not punish the mistake and blew several chances to score themselves before Tonga captain Inoke Afeaki crashed over for the first try of the match.
Hola's conversion put Tonga 7-3 up and Canada faced the very real possibility of going into the break behind despite the wind.
Two Ross penalties enabled them to earn a slim advantage, but they lost inside centre Nikyta Witkowski when Pila Fifita accidentally trod on him in broken play just before the half-hour mark.
The incident came a moment after a clearing kick from Winston Stanley nearly killed a seagull, although the bird escaped with just some feathers missing.
Sukunaivalu Hufanga brought the 15,630-strong crowd to life when he tore through a hole in the Canadian line, only a super tackle from Quentin Fyffe stopping the replacement centre scoring a great individual try.
Hufanga cut through again a moment later, this time the defenders stopping him and then stealing possession to clear the danger.
Hufanga was to the fore once more in the 65th minute with yet another incisive run at the heart of the Canadian defence and his team raced to support him, only for Martens to fumble as the movement moved to the left.
After Charron was taken off, Canada extended their lead when Ross kicked his fourth penalty to make it 17-7 with six minutes left.
Tonga, knowing they needed to score quickly, surged forward and were just held up over the line and in the closing minutes the Canadians refused to buckle.
Indeed, in the dying moments Canada scored after replacement James Pritchard was taken out on a counter-attack out by David Palu, who was sinbinned and conceded the penalty.
From the next scrum Abrams was driven over and Ross converted to seal the win.Reuse content