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.
Source: Anadolu Agency