Japan produced a stunning comeback to beat Spain 2-1 and secure top spot in World Cup Group E.
Spain had looked in total control at half-time after taking the lead through Alvaro Morata’s early header.
Japan, though, turned things around in the space of five minutes at the start of the second half when substitute Ritsu Doan equalised before Ao Tanaka netted another – which was allowed to stand following a lengthy VAR review after the ball had appeared to have gone out of play.
Japan, who had opened their campaign with a shock win against Germany but then were beaten by Costa Rica, almost snatched an early lead when Junya Ito fired into the side-netting.
Spain went in front in the 11th minute when Morata headed in a cross from the right by Chelsea captain Cesar Azpilicueta for his third goal of the tournament.
As news came through of Germany scoring an early goal against Costa Rica, the Samurai Blue fans became subdued, mirroring their team on the pitch.
There was a rare moment of action in the Spain penalty area just after the half-hour mark when goalkeeper Unai Simon dwelt on the ball a bit too long, and Daizen Maeda almost capitalised.
Spain continued to dominate possession and although it looked only a matter of time before they would open up the Japan defence again, there were no more goals ahead of the break.
Japan coach Hajime Moriyasu made a double change for the second half, with Brighton midfielder Kaoru Mitoma and Doan sent on for Yuto Nagatomo and Takefusa Kubo. Spain full-back Azpilicueta was replaced by Dani Carvajal.
The changes made an instant impact as Japan equalised three minutes after the restart.
Spain were caught trying to play out from the back as Freiburg winger Doan picked up possession just outside the penalty area and drilled a shot past Simon, who could only palm the ball into the top left corner.
Japan completed another remarkable turnaround when they took the lead in the 51st minute.
Doan was again involved as his low cross went right through the six-yard box and was cut back in by Mitoma from the goal-line at the far post, with Tanaka bundling the ball home.
A lengthy VAR check followed and officials eventually ruled the whole of the ball had not crossed the line – a decision which sparked pandemonium among the now jubilant Samurai Blue faithful.
Spain boss Luis Enrique reacted by replacing Morata with Marco Asensio and sending on Ferran Torres for Nico Williams.
Japan created another good opening with 20 minutes left.
Mitoma broke down the left and clipped a pass back across to the edge of the penalty area where Takuma Asano arrived at pace, but the Bochum forward could only skew his shot wide.
Spain pushed for an equaliser and Japan goalkeeper Shuichi Gonda made a smart reaction save to push away a low drive from Asensio before then collecting Dani Olmo’s angled shot at the near post as Japan celebrated another remarkable victory and a place in the last 16.
Celtic’s Daizen Maeda played an hour up front for Japan and is one of four Hoops stars to have reached the last-16 after successful group stages for Aaron Mooy, Cameron Carter-Vickers and Josip Juranovic.