Hosts Japan moved closer to a first World Cup quarter-final with a dramatic bonus-point victory over Samoa.
The sides exchanged three penalties in a nervy start before Samoan-born centre Timothy Lafaele scored the opening try.
Kazuki Himeno, Kenki Fukuoka scored after the interval before Kotaro Matsushima sealed the late bonus point, while Henry Taefu scored a consolation.
Japan top Pool A and will qualify if Scotland fail to beat them and Russia in their final two matches.
The unbeaten Brave Blossoms face Scotland in the final pool game on Sunday, 13 October (11:45 BST).
Samoa, who are out of the tournament, will end their campaign against Ireland on 12 October (11:45).
Japan are nearly there
Victory all but sealed qualification for the last eight but Japan will be taking nothing for granted because they have been here before.
Three victories in the pool stages four years ago were not enough to progress for Jamie Joseph’s side, who were then under England coach Eddie Jones’ leadership.
And there were signs of those nerves early on as Japan struggled to take a real grasp of the game, although Yu Tamura showed composure from the tee.
The breakthrough moment came when talismanic leader Michael Leitch turned over the ball to release the dangerous Matsushima. The ball was recycled and Lafaele crossed the line to send the City of Toyota Stadium into raptures.
Taefu was equally competent with his goal-kicking and he pegged the hosts back after the interval before Himeno added the second try with a well-worked move from the line-out.
Samoa, who were chasing a losing bonus-point to keep their slim hopes alive, hit back through Taefu but Japan regained the initiative when they moved the ball wide for replacement Fukuoka to score in the corner.
And with the clock in the red, the bonus point was sealed with the last act from open play as Matsushima scored his fourth try of the tournament.
A win against Scotland in the final pool match will be enough to take Japan through with the Scots having to first beat Russia on Wednesday.
Japan: Nakayama; Matsushima, Lafaele, Nakamura, Lemeki; Tamura, Nagare; Inagaki, Sakate, Ji-won, Van der Walt, Moore, Leitch, Labuschagne, Himeno
Replacements: Horie, Nakajima, Ai Valu, Helu, Tui, Tanaka, Matsuda, Fukuoka
Samoa: Nanai-Williams; Tuala, Leiua, Taefu, Fidow; Seuteni, Polataivao; Lay, S Lam, Alaalatoa, Faasalel, Le’aupepe, Vui, Ioane, J Lam
Replacements: Niuia, Alo-Emile, Lay, Toleafoa, Tyrell, Cowley, Pisi, Fonotia