Kotaro Matsushima crossed with the final action of the match to earn Japan a bonus point as they climbed to the top of Pool A with a battling win against Samoa on Saturday.
The World Cup hosts claimed a shock victory over Pool A favourites Ireland last time out, but Samoa put up a good fight in Toyota City and looked like denying the Brave Blossoms the maximum haul until Matsushima touched down with the clock having passed 80 minutes.
Timothy Lafaele, Kazuki Himeno and Kenki Fukuoka also scored for Japan, while Henry Taefu accounted for all of Samoa's points.
The result sends Japan three points clear of Joe Schmidt's men at the summit and ends their opponents' slim hopes of a place in the last eight.
The boot of Yu Tamura fired Japan into a 6-0 lead before Taefu got Samoa on the board from the tee after 10 minutes.
Taefu and Tamura exchanged a further kick apiece before TJ Ioane was sin-binned for a late tackle, reducing Samoa to 14 men for 10 minutes - a fifth yellow card of the tournament for Steve Jackson's side.
Japan capitalised on their numerical advantage as Lafaele touched down following a fantastic run from Matsushima, Tamura adding the extras.
Taefu's third three-pointer saw Samoa go in 16-9 down at the break and he split the posts again early in the second to further reduce the deficit, before Tamura atoned for his first miss of the match by reestablishing Japan's seven-point lead.
Jamie Joseph's men finally gave themselves breathing space with Himeno's try from a driving maul, but Taefu added a converted try to his personal points haul six minutes from time to give his side hope of clinching at least a losing bonus point.
However, Japan pulled clear in the closing minutes, as Fukuoka and Matsushima went over in opposite corners to earn Japan an important bonus point of their own.
Follow Ireland v Samoa on Saturday 12 October (kick-off 11.45am) via the live blog on RTÉ.ie/Sport and the News Now App, watch live on RTÉ2 or listen to live match commentary on RTÉ Radio 1.