Germany were knocked out of the World Cup in the group stage for a second consecutive time despite a 4-2 win over Costa Rica on Thursday after the four-times champions were consigned to third in Group E following Japan's victory over Spain.
Costa Rica deployed a five-man backline but Germany still found a way through in the 10th minute when David Raum floated in a cross that was headed home by Serge Gnabry, who restarted the game quickly fearing goal difference being a factor.
But after learning that Japan were leading Spain in the other group game, Germany let their guard down and Costa Rica scored twice with Yeltsin Tejeda arriving late to score the first before Juan Pablo Vargas bundled a second over the line.
Germany's Kai Havertz grabbed a brace after coming on as a substitute to seal the three points before Niclas Fuellkrug added a fourth late in the game but the final results left Japan at the top of the group while Spain finished second.