Japan rallied from a goal down on Thursday night to shock European giants Spain 2-1 in the concluding match of Group E to finish on top of the group and qualify for the knockouts of the 2022 FIFA World Cup.
Despite the defeat, Spain was the second team to qualify for the Round of 16 from the group, ahead of Germany on goal difference.
It was Spain that took the lead in the Group E match with Alvaro Morata scoring the opener in the 11th minute. The teams went into half time after just the one goal. The Samurai Blue however stormed back with full gusto in the second half to score two goals within a span of three minutes.
Coach Hajime Moriyasu's team drew level through Ritsu Doan in the 48th minute and then took the lead with a goal from Ao Tanaka three minutes later.
Japan, who have set a target of qualifying for the last-eight stage of the tournament, had opened their campaign with a 2-1 win over four-time winners Germany but lost to Costa Rica.
Spain on the other hand started with 7-0 drubbing of Costa Rica and followed it up with a one-all draw with Germany.
In the other match at Al Bayt Stadium in Al Khor, Germany defeat Costa Rica 4-2 in a six-goal thriller which was officiated by a first all-female on-field refereeing team at men's World Cup.
Germany's winning effort fell short and was not enough as they finished with just four points from three matches, the same as Spain, but La Roja qualified on a better goal difference.
Japan's 2-1 win over Spain meant Japan and Spain were through, Japan finished with six points from two wins and loss.
On Thursday, both Group E and Group F had surprising group winners. Group E champion Japan will face Croatia in the round of 16 on Monday. Group F winner Morocco will face Spain on Tuesday.
The World Cup continues Friday, when the Round of 16 will be finalised after the finales in Group G and Group H.
Japan coach Moriyassu's last-eight target, set at the start of the tournament, is now a step away.
He has had some bitter memories of Qatar as a player, as he was part of the Japan team which missed out on the chance to qualify for the 1994 World Cup Finals as they were within seconds of reaching their first finals only to concede a stoppage-time equaliser to Iraq which sent arch-rivals South Korea through instead.
That crushing moment is known as the "Agony of Doha" but while Japan's biggest football setback may never be forgotten, the Samurai Blue are determined to reverse their fortunes and make Qatar the stage for their best World Cup performance.
Japan have since put the 1994 set behind them and since debuting in 1998 have qualified for seven successive World Cup tournaments and a last-eight finish is finally within Japan's reach despite featuring in a tough group feels Moriyasu, which he has reiterated time to time ahead of their opening match.