Hansi Flick’s side were third in Group E on goal difference behind La Furia Roja, thanks to the 7-0 win over Costa Rica.
But Spain were almost out of the tournament themselves when Los Ticos took the lead.
There was great controversy surrounding Ao Tanaka’s goal and whether the ball was out of play, but now Japan book a date with Croatia, and Spain are left to take on Morocco in the last 16.
Here is a timeline of how the night unfolded and the dramatic rise and fall of each side as Group E was shaken up:
- 10′: Goal Germany, 1-0! Serge Gnabry breaks the deadlock and the Germans are up to second on more goals scored (three to Japan’s two, with both sides on 0 goal difference), with Spain still top on five points.
- 11′: Goal Spain, 1-0! Alvaro Morata scores as Spain stretch their lead on top to three points with seven total themselves, while Japan now trail Germany in second by a point.
- 48′: Goal Japan, 1-1! Ritsu Doan strikes and Japan are level again on points with Germany, but go up into second due to their superior head-to-head after the 2-1 win in the first round of fixtures – both sides have 0 goal difference and also have both scored three goals apiece
- 51′: Goal Japan, 1-2! Ao Tanaka’s controversial goal puts Japan into first on six points, Spain drops down to second on four points, level with Germany but ahead on a superior goal difference, +6 compared to Germany’s 0
- 58′: Goal Costa Rica, 1-1! Yeltsin Tejeda equalizes and puts Germany in big trouble, they go down to fourth on two points, Los Ticos are third and behind Spain, also on four points, on goal difference alone, -6 vs +6
- 70′: Goal Costa Rica, 1-2! A Manuel Neuer own-goal puts Los Ticos 2-1 up and into second, level with Japan on six points, but behind on goal difference (-5 vs 0), and two points clear of Spain in third and five clear of Germany, who are bottom on one point at this stage
- 73′: Goal Germany, 2-2! Kai Havertz equalises and Germany remain fourth on two points, but now require one more goal themselves and one from Spain to edge out Japan on goals scored again.
- 85′: Goal Germany, 3-2! Havertz again and now Germany are up to third and behind Spain on goal difference, with Japan still top on six points
- 89′: Goal Germany, 4-2! Niclas Fullkrug hits a fourth for Germany, but it’s not enough as Japan hold on for the win to top Group E on six points, with Spain holding off Germany for second with +6 goal difference vs Germany’s +1