A tight, grinding game was broken open by two pieces of Samoan brilliance early in the second half of their win.
Leading 10-8 at the break, Samoa scored two converted tries to streak away to a 16-point lead that was never threatened.
First, Paul Ah Him broke through in midfield before popping an inside ball to centre Nathaniel Apa, nephew of the legendary Michael Jones.
Shortly after, first five-eighth William Talataina Mu scooped up a loose ball and hared away for a solo try.
Scotland and Samoa had been turned over easily in their opening matches, by South Africa and New Zealand respectively, so required a win with a bonus point to keep alive faint hopes of making the semifinals. Samoa came close to scoring a fourth try on a couple of occasions, but could not quite seal the deal.
Scotland, to their credit, never allowed Samoa to feel comfortable in the lead.
France had their second win of the tournament with their convincing win over Fiji.
The French showcased their attacking flair by cutting loose in the second half after leading 8-0 at the break. The French scored five tries in the second spell, including a penalty try soon after halftime.
Ireland finished strongly in a tightly contested match after leading 17-14 at halftime. It was Ireland's first win of the championship and a win against Fiji on Friday will give them a chance of progressing further.