The Samoans looked to be slipping to a surprise defeat after Canada's Sale Sharks wing Phil Mackenzie raced over for an opportunistic converted try to put the home side 20-16 up with four minutes left.
But Samoa punished a needlessly conceded penalty by setting up a line-out on Canada's goal-line with just seconds left.
And when Canada knocked on from the set-piece, Sakaria Taulafo was on hand to touch down for the winning score.
Canada had raced into a 13-0 lead through a try from centre Nick Blevins and eight points from the boot of full-back James Pritchard.