Photo/Illutration Japan's Kaoru Mitoma just barely prevents the ball from crossing the endline against Spain at Khalifa International Stadium in Doha, Qatar, Dec. 1. (AP Photo)

Japan defeated Spain at the World Cup in Qatar by a matter of millimeters.

A Video Assistant Referee (VAR) ruling was needed after Samurai Blue went up 2-1 against Spain in their final Group E game on Dec. 1.

With the score tied 1-1, Japan substitute Ritsu Doan kicked the ball in front of the Spanish goal around six minutes into the second half.

The ball slid by the goal post and moved toward the endline. Kaoru Mitoma slid and kicked the ball back in front of the goal, and Ao Tanaka knocked it into the net for the go-ahead score.

The Spanish team immediately protested. And on TV screens, the ball did appear to cross out of bounds before Mitomi could touch it.

The judges spent about two minutes checking video replays of that moment.

According to soccer rules, the entire ball must be completely out of bounds for the play to be called dead.

20221202-worldcup3-1-L
From this angle, the ball appears to be out of bounds in the second half of the Japan-Spain match in Qatar on Dec. 1. (Tatsuro Kanai)

From their angle, TV viewers and those at the stadium likely saw a small green patch of pitch between the ball and the goal line, and presumed the ball was indeed out.

But that was just the bottom of the ball.

An aerial view, as seen by the VAR judges, showed the side of the ball was barely above, and therefore touching, the goal line, meaning it was still in play.

So instead of giving Spain a goal kick, the referee signaled that Japan’s goal stood, and the team and its fans erupted again in celebration.