Japan pulled their Qatar World Cup campaign out of the fire with another come-from-behind win over a soccer superpower, beating Spain 2-1 on Thursday to earn a place in the round of 16.

After another first half in which his team were completely outplayed, Hajime Moriyasu called on super sub Ritsu Doan to again save the day at the Khalifa International Stadium.

Doan did his part, echoing his role in Japan's 2-1 comeback win over Germany to open their tournament. The Freiburg attacker more than answered Alvaro Morata's early first-half goal, netting a stunning equalizer and following with a cross that led to Ao Tanaka scoring the Samurai Blue's second.

Japan players celebrate after Japan qualified for the round of 16 by beating Spain 2-1 in a World Cup Group E football match at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo) ==Kyodo

The win for Japan combined with Germany's 4-2 victory over Costa Rica means the Samurai Blue top Group E, what many labeled the tournament's group of death, with six points.

"The team played tenaciously and with confidence," said Moriyasu, who came under fire for Japan's 1-0 loss to group underdogs Costa Rica on Sunday.

"It was tough in the first half and also throughout the game, but the players believed they could do it and played as a team through to the end."

Ritsu Doan (8) celebrates with Kaoru Mitoma (9) and Ao Tanaka (17) after equalizing for Japan during the second half of a World Cup Group E match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)
Ao Tanaka (17) reacts after scoring Japan's second goal during the second half of a World Cup Group E football match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo) ==Kyodo

Spain scraped through to the last 16 in second place on four points, ahead of Germany on goal difference. Costa Rica joined the four-time champions in exiting from the group stage.

Japan's win sets them up for a final 16 meeting with 2018 runners-up Croatia on Monday, while Spain will meet Morocco, the winner of Group F.

Japan reached the knockout phase in consecutive World Cups for the first time.

The first goal came when Cesar Azpilicueta put a cross onto Morata's head in the five-yard box, the Atletico Madrid player rising uncontested in a gaping hole between a grasping Ko Itakura and Maya Yoshida to put the Europeans into the lead.

Spain's Alvaro Morata (7) heads the opening goal during the first half of a World Cup Group E match against Japan at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)
Spain's Alvaro Morata celebrates after opening the scoring during the first half of a World Cup Group E match against Japan at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)

Morata has now scored in each of Spain's games in Qatar, twice off the bench and on Thursday as a starter, and he is in joint lead of the Golden Boot race with France striker Kylian Mbappe.

Spain had 78 percent of the possession in the first half and had six shots to Japan's two.

The Samurai Blue's best chance came from the foot of Junya Ito in the seventh minute. The Reims winger took a couple of touches when the ball fell to him on the right side of the box and blasted into the goal's side netting.

Japan's Junya Ito (L) shoots during the first half of a World Cup Group E match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)

Halftime sub Doan brought Japan back into the game in the 48th minute with a wonderful left-footed strike that caught Spanish keeper Unai Simon napping. The Athletic Bilbao stopper could only deflect a shot he should have pushed wide.

"That was my favorite area and I had decided I'd take a shot if I got the ball. I put all my power on it," said Doan, who replaced Takefusa Kubo after the interval. "We had to go on the offensive and I was told to be aggressive."

Doan popped up again immediately with the cross that led to Japan's second.

Ritsu Doan (8) equalizes for Japan during the second half of a World Cup Group E match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)
Ritsu Doan (8) celebrates with his teammates after equalizing for Japan during the second half of a World Cup Group E match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)

The ball was brilliantly kept from crossing the byline by fellow substitute Kaoru Mitoma. The Brighton & Hove Albion man dragged it back for Tanaka to knee into the goal in the 51st minute, though both teams had an agonizingly long wait for confirmation from the video assistant referee.

Top photo shows Kaoru Mitoma of Japan (L) keeping the ball from fully crossing the line before setting up his team's second goal during a World Cup Group E football match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022, while bottom photo shows Ao Tanaka (2nd from R) meeting Mitoma's cross to score. (Kyodo) ==Kyodo
 
A big screen shows the VAR decision to allow Ao Tanaka's goal in the second half of Japan's 2-1 victory over Spain in a World Cup Group E match at Khalifa International Stadium in Doha on Dec. 1, 2022. The goal was initially ruled out by the assistant referee who signalled Ritsu Doan's cross had gone out of play. (Kyodo)
Ao Tanaka (L) reacts after scoring Japan's second goal during the second half of a World Cup Group E football match against Spain at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo) ==Kyodo

With their World Cup future hanging in the balance, Spain pushed forward in hopes of snagging an equalizer. But Japanese keeper Shuichi Gonda made two 89th-minute saves to ensure Moriyasu's men completed another stunning comeback.

Tanaka said the Samurai Blue squad had not let the disappointment of the loss to Costa Rica, which jeopardized their bid to reach the round of 16, affect their mindset against Spain.

"We lost the last game and there might have been a sense of resignation (outside the camp), but we always believed," Tanaka said.

"It would have been ideal to keep (Spain) scoreless but we were resigned to conceding one. But the fact we could turn the game around after Ritsu's goal is because we have the ability."

Japan players celebrate after a 2-1 win over Spain in a World Cup Group E football match at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. Japan advanced to the round of 16. (Kyodo) ==Kyodo
Japan head coach Hajime Moriyasu (C) and his players huddle on the pitch after a 2-1 win over Spain in a World Cup Group E football match at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. Japan advanced to the round of 16. (Kyodo) ==Kyodo
 

Related coverage

Football: Make every World Cup test a positive, Moriyasu tells Japan

Football: Spain game most important of my career, says Japan's Yoshida

Football: Olympic heartbreak gives Japan's Doan confidence at World Cup