Former world champions Germany, which placed 3rd with goal difference, eliminated. (Anadolu photo)

ANKARA – Japan beat Spain 2-1 in Group E on Thursday but both nations reached the 2022 FIFA World Cup Round of 16.

Spain reached the Round of 16 as well by finishing in second spot with four points, while former champions Germany, which placed third with goal difference, were eliminated.

Sergio Busquets missed a good chance for Spain in the sixth minute at the Khalifa International Stadium.

Japan's Junya Ito missed the Spanish goal by inches in the eighth minute.

Alvaro Morata's header was saved by Japanese goalie Shuichi Gonda in the ninth minute, but just two minutes later, Morata scored Spain’s first goal with a header.

Spain winger Nico Williams' shot from a narrow angle deflected to the corner in the 46th minute and the first half ended 1-0.

Japan kicked off the second half with the wind on their backs.

Japan's Ritsu Doan, who got into the match in the halftime break, leveled the score in the 48th minute.

Japanese midfielder Ao Tanaka shocked the Spaniards as he netted another one just three minutes later.

Takuma Asano missed a good chance to score for Japan in the 70th minute.

Marco Asensio and Dani Olmo's promising attempts on Japan’s goal were denied by keeper Gonda in the 89th and 90th minutes, respectively.

The Japanese held their ground until the final whistle, winning the match 2-1 and topping Group E with 6 points.

Eliminated

Meanwhile, Germany was eliminated from the group stage, despite beating Costa Rica 4-2 on Thursday.

In the 10th minute at Al Bayt Stadium, Germany scored the opener as Serge Gnabry's header beat Costa Rica goalkeeper Keylor Navas.

Costa Rica leveled the match in the 58th minute as Yeltsin Tejeda scored after a rebound by German goalkeeper Manuel Neuer.

Several minutes later, Germany star Jamal Musiala hit the crossbar twice.

Costa Rica took a surprising 2-1 lead in the 70th minute as Juan Pablo Vargas scored from close range.

Only a few minutes later, Germany's Kai Havertz finished in the box to make it 2-2.

In the 85th minute, Germany came back as Havertz was on the score sheet again.

Germany forward Niclas Fullkrug made a close-range finish. His teammate Leroy Sane beat Costa Rica's offside trap to assist Fullkrug.

Germany, the 2014 World Cup winners, secured a 4-2 win, but they were eliminated on goal difference.

Japan won Group E with six points. The Asian team beat Germany and Spain.

Spain, who were the 2010 champions, came second with four points. The Spanish had a six-goal difference in the group.

Third-placed Germany have four points, but their goal difference was one, less than Spain.

The Germans experienced a shocking group-phase elimination in the previous World Cup in Russia.

Costa Rica have three points to occupy the bottom of Group E. So Germany and Costa Rica returned home after their third matches.

Japan will next take on Croatia, and Spain will face Morocco in the last 16 in Qatar. (Anadolu)