Both teams entered the match promising to run the ball at every opportunity and were true to their word, matching each other almost try for try in the match at Apia Park.
The teams went to halftime locked at 17-17 but Samoa eked out a small advantage in the second half in a skillful and fast-paced match.
The result lifted Samoa to third and Japan to fifth place in the six-nation competition. Tonga, which beat Fiji Saturday for their first win of the tournament, still finished in last place while Fiji dropped back to fourth.
Samoa's tries on Saturday went to veteran loose-forward Semo Sititi, Loleni Tafunai, Heroshi Tea, Anitelea Tuilagi and James Johnson while Gavin Williams, son of former All Black Bryan Williams, kicked three conversions and two penalties.
Japan scored tries through Hare Makiri, winger Bryce Robins, Hirotoki Onozawa and Takashi Kikutani. James Arlidge converted all four tries and kicked a penalty.
Scores:Samoa 37 (Semo Sititi, Loleni Tafunai, Heroshi Tea, Anitelea Tuilagi, James Johnston tries; Gavin Williams 3 conversions, 2 penalties), Japan 31 (Hare Makiri, Bryce Robins, Hirotoki Onozawa, Takashi Kikutani tries; James Arlidge 4 conversions, penalty)