Japan once again stunned the World Cup in Qatar with another giant-killing effort Thursday that kept the Samurai Blue on course for their first quarterfinals and sparked jubilant celebrations among players and fans.

Staring at a potential exit, Hajime Moriyasu's side evoked their earlier victory over Germany as they came back to beat Spain 2-1 and top Group E on a night likely to be remembered as one of the most enthralling in the tournament's long history.

(From L) Kou Itakukra, Ritsu Doan and Takehiro Tomiyasu celebrate after Japan's 2-1 win over Spain in a World Cup Group E football match at Khalifa International Stadium in Doha, Qatar, in the small hours of Dec. 2, 2022. Japan advanced to the round of 16. (Kyodo) ==Kyodo

"I'm speechless. This is why you can't quit the national team. (It's the) best feeling ever," said 34-year-old captain Maya Yoshida, who gained redemption for a misplaced pass that enabled Costa Rica to upset Japan 1-0 on Sunday.

"We've watched some of (Spain's) matches and we also found it very tough facing them playing four at the back last summer at the Olympics (semifinal in Tokyo), so the plan was to have three or five at the back and play patiently."

"Our original target was to win the next game. Everyone was also saying today they can't go home yet."

Japan captain Maya Yoshida (R) and Hidemasa Morita celebrate after the team's 2-1 defeat of Spain in a World Cup Group E match at Khalifa International Stadium in Doha, Qatar, on Dec. 1, 2022. (Kyodo)

Alvaro Morata headed home the 11th-minute opener during a deja vu of Japan's underwhelming first-half display against Germany, hardly venturing forward and saving their best for the second half.

Needing a win to ensure their place in the last 16, Japan resisted the impulse to attack from the start with Moriyasu and his players taking a measured approach against one of the tournament favorites.

The Asian side succeeded in making lightning strike twice, once again beating former World Cup champions by grabbing goals on the break and shutting up shop following another half-time reshuffle from Moriyasu.

"We persevered to leave everything for the second half, like the Germany game. I'm glad it worked out well," said Yoshida. "The second half was incredibly long. But we were OK as long as we got that defensive block laid out. It's thanks to everyone's effort."

Half-time substitute Kaoru Mitoma was again a vital cog for Japan, desperately stretching his left leg to keep the ball in play by millimeters on the byline and set up Ao Tanaka's 51st-minute winner. The Brighton attacker also worked his socks off defensively until the final whistle.

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

The 25-year-old rising star said Japan's wins over Germany and Spain were something to be remembered for a long time.

"They're two massive wins within the whole World Cup (narrative)," said Mitoma. "We can make history if we manage to reach the last eight next, so we'll refocus."

Yuto Nagatomo, who has become the first Japanese player to appear in four straight World Cups, said he had presaged the outcome.

Japan's Yuto Nagatomo (L) makes a pass 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)

"I had this exact image (of winning) popping up in my mind two days ago. Bravo to all the teammates, the manager, the fans here and everyone back home," the 36-year-old former Inter defender said.

"Of course we sense good things (now) after going through a very tough three days (following the loss to Costa Rica). But we showed our resilience and went into the game with strong determination."

Japan made the last 16 on three occasions in the past starting with 2002 and Nagatomo, who reached that stage in 2010 and 2018, wants to go one further.

"I've had two really frustrating moments and I absolutely want to win and see new scenery, with everyone part of this best team ever," the veteran said.

Japan's Takefusa Kubo (R) goes on the attack 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)

One player who may have felt particularly disappointed had Japan not prevailed was Barcelona youth product Takefusa Kubo, who was replaced at the break despite arguably being his side's best until that point.

The 21-year-old, whose early withdrawal also meant he missed the chance to face his La Masia teammate, Spanish second-half substitute Ansu Fati, was eager to quickly get back in action.

"Honestly speaking, I believe I was the best player in the first half," said Kubo. "But Doan came on for me and scored. I'd have been left unfulfilled otherwise, so I'm grateful. I hadn't packed my bag yet and I'm relieved we're not going home at this stage."

Japan's attention now turns to a last-16 showdown with 2018 runners-up Croatia on Monday.

"We don't know how Croatia play, but losing after beating these two teams (Germany and Spain) would be wasteful," Kubo said. "It's all over with a loss from here, we can etch our names into Japanese history books with one more win, and I want my name to be among them."

Related coverage:

Football: Japan rise from dead again to beat Spain and reach last 16

Football: 5 things learned after Japan's 2-1 comeback against Spain

Football: Moriyasu's Doha scars no burden for Japan's "new age" players