Hosts Japan moved closer to a first World Cup quarter-final with a dramatic bonus-point victory over Samoa at the City of Toyota Stadium on Saturday.
Kotaro Matsushima scored a bonus-point try deep into injury time to secure a crucial bonus point for Japan,
Japan moves to the top of the pool with 14 points and also secured their third victory in the pool phase for the second successive World Cup.
The loss ended the Pacific Islanders' chances of their first place in the knockout phase since 1995, although the grouping is not likely to be decided until Japan play Scotland in Yokohama in the last game of the pool phase on October 13.
Loose forward Kazuki Himeno, centre Timothy Lafaele and winger Kenki Fukuoka also scored tries for Japan, while five-eighth Yu Tamura added 18 points with the boot in front of a passionate crowd of just under 40,000.
Ireland are second in the pool with 11 points while the Scots, with a game in hand, have five.
Japan took a 6-0 lead through two penalties from Tamura, but a couple of indiscretions at the ruck allowed Samoa to level the score through centre Henry Taefu.
But Samoa's discipline issues in this tournament continued when flanker TJ Ioane was sent to the sin bin for a no-arms tackle, their fifth yellow card.
Matsushima made an incisive break towards the Samoan line and, after he was brought down five metres short, the ball was fed out to Samoan-born Lafaele to cross over for a 16-9 halftime advantage.
The teams traded penalties at the start of the second period before Japan scored a second try on 56 minutes to open up some daylight on the scoreboard.
They got a massive shove going in the maul from an attacking lineout and Himeno collapsed over the line.
But Samoa showed admirable fighting spirit and, after dominating possession and winning a succession of penalties inside the Japan 22, Taefu crossed to bring them back into the contest.
But Japan, roared on by their home support, drove the ball towards the Samoan line from the kick-off and Fukuoka crossed in the corner, before the lively Matsushima secured the bonus-point with the final play of the game.
Japan 38 (Kenki Fukuoka, Kazuki Himeno, Timothy Lafaele, Kotaro Matsushima tries Yu Tamura 3 cons 4 pens)
Samoa 19 (Henry Taefu try con 4 pens)
Join us at 5:45pm Sunday for live updates of the All Blacks v Namibia Rugby World Cup clash.