AL RAYYAN, Qatar (AP) -- The "Agony of Doha" came 29 years ago, and Hajime Moriyasu experienced it first-hand as a midfielder on Japan's national soccer team.
He's now the coach, and he's made amends.
Japan won its World Cup group on Thursday after beating 2010 champion Spain 2-1 at the Khalifa International Stadium. Last week, the team defeated 2014 champion Germany by the same score at the same venue.
As time was winding down against Spain, Moriyasu was thinking about that game in Qatar against Iraq in 1993 that cost the team a spot in the next year's tournament.
"About one minute before the end," Moriyasu said after the win over Spain, "I remembered the tragedy in Doha."
Leading 2-1 in the team's final qualifier and knowing one goal for the opposition would spell the end, Japan conceded in stoppage time. Their World Cup hopes were dashed, and so was Moriyasu's chances of playing at the biggest soccer tournament in the world.
This time it was different. This time the defense held it together. This time the 54-year-old Moriyasu got his Hollywood ending by winning Group E.
"I could feel that the times have changed," Moriyasu said, praising his team's aggressive defending. "They are playing a new kind of soccer, that's how I felt."
Japan's resistance on the field was typified by 34-year-old captain Maya Yoshida. The veteran central defender reacted fastest when a loose ball in the 90th minute bounced in the goalmouth, up in front of a gaping empty net, after goalkeeper Shuichi Gonda blocked a shot by Jordi Alba.
Yoshida twisted his body to beat Marco Asensio to the ball and clear the danger. When Spain forward Dani Olmo took control seconds later, Gonda blocked his shot with a smothering dive.
On the offensive side, Japan scored in the 48th and 51st minutes. Against Germany, the goals came in the 75th and 83rd.
"In 10 minutes we were dismantled," Spain coach Luis Enrique said.
Up next is Croatia, a team that reached the final four years ago in Russia. Another victory on Monday would put Japan in the World Cup quarterfinals for the first time.
"We," the coach said, "are gifting this win to the people of Japan."