In Group E's last match, Japan defeated Spain 2-1, although not without controversy.
The outcome eliminates Germany from the World Cup, as they will not advance to the following round for the second consecutive tournament.
Germany defeated Costa Rica 4-2 on Thursday afternoon, but it was not enough as Japan's win at the same time meant Japan won Group E with its victories over Germany and Spain, while Spain moved to the round of 16 in second place by goal difference.
The only way Germany could have qualified as if they duplicated Spain's 7-0 victory over Costa Rica in their opening match to have any tiebreaker advantage.
Germany exits
Germany defeated Argentina in a thrilling final to win the 2014 World Cup.
In 2018, however, the Germans finished last in their group behind Sweden, Mexico, and South Korea to become the third defending World Cup champion to fail to advance past the group stage.
France snapped the run by winning Group D in the 2022 World Cup.
How the game went
Alvaro Morata gave Spain an early 1-0 lead in the eleventh minute.
In the first seven minutes of the second half, Japan scored a pair of goals.
The goals were scored in less than four minutes.
Ritsu Doan scored in the 48th minute to draw the game.
Then, Ao Tanaka scored a disputed goal to put Japan in front.
The game-winning goal was first disallowed because it believed the ball had left the field of play.
A video review, however, ruled that the ball remained in play, as the ball's complete circumference must pass the out-of-bounds line for it to be considered out of space.
Statistics revealed that Japan averaged just 18% possession throughout 90 minutes, completing 175 passes compared to Spain's 991.
Japan will face Croatia in the Round of 16 due to the victory since Croatia drew with Belgium.
Japan has earned its second consecutive participation in the knockout stage.
Four of their last six World Cup appearances have resulted in the Round of 16.