As Japan began wildly celebrating their strike to go 2-1 up against Spain, the referee ruled the ball had gone out of play before the final pass and disallowed the goal.
The video assistant referee (VAR) then took another look, and calculated a tiny fraction of the ball had stayed in play.
It was enough to eliminate four-time winners Germany, who were playing Costa Rica in Group E’s other fixture.
Going into last night’s matches, all four teams in Group E were still in the race to qualify for the knockout stage.
But Japan needed a win against favourites Spain to guarantee their berth in the round of 16.
Alvaro Morata headed Spain into the lead in the 11th minute, and the future was looking bleak for Japan at half-time.
The Blue Samurai returned after the break knowing that they needed a win since Germany were 1-0 up against Costa Rica.
Japan’s Ritsu Doan unleashed a long-range strike to equalise in the 48th minute.
Then Kaoru Mitoma chased a ball to the byline before cutting it back for Ao Tanaka to make it 2-1. Referee Victor Gomes quickly interrupted Japan’s celebrations to rule the ball had gone out of play before the goal.
However, VAR overturned his decision after the positional sensor in the Al Rihla ball showed it had stayed within the field of play.
According to Fifa rules, the ball is only out of play when every part crosses the line.
In other words, if a line is drawn straight up from the byline, and that line intersects with any part of the ball, the ball is still in play.
Fifa also offered an explanation after the game, saying the “curvature of the ball” kept it in play.
The goal was crucial, as Japan needed a win to qualify since Germany beat Costa Rica 4-2.
Japan finished top of Group E and will face Croatia in the round of 16, while second-place Spain will play Morocco.
Related stories