Germany sensationally crashed out of the World Cup despite beating Costa Rica at Al Bayt Stadium, with Japan stunning Spain to send Der Team home at the group stage - just like in 2018.
Hansi Flick's team knew nothing less than a victory could send them into the last 16, but Japan's win in the other game meant they faced the improbable task of making up seven goals on Spain. Serge Gnabry put them ahead at the break, but goals from Yeltsin Tejeda and Juan Pablo Vargas briefly put Costa Rica into the qualification spots.
Luis Fernando Suarez's team couldn't hold on, though, and a Germany side who hit the post several times eventually completed their turnaround. A Kai Havertz double put Flick's men back in charge, before Niclas Fullkrug scored his second goal in as many games to make it 4-2, but it was too little, too late.
When Flick's men first took the lead, it looked like a case of how many. Instead, though, the CONCACAF side found a response in a similar manner to Japan in Germany's first group game, with Keysher Fuller stinging the palms of Manuel Neuer before levelling through Tejeda.
Jamal Musiala and Antonio Rudiger both hit the woodwork in pursuit of another goal, and Musiala then did so for a second time. Instead, though, it was the underdogs who scored the game's third goal, through Vargas, after a VAR check.
Fullkrug was one of the players introduced in the second period, looking to add to the crucial equaliser he scored against Spain. The striker had a golden chance to put his team back in front, only to fire an effort into the face of goalkeeper Keylor Navas from point-blank range.
Who will win the World Cup? Have your say in the comments section
While all this was going on, the other group game between Japan and Spain took a number of twists and turns of its own. Alvaro Morata had put Luis Enrique's side in front at the break, but they too were hit by a quickfire double.
Japan struck through Ritsu Doan and Ao Tanaka, making for a frantic end to the game. Tanaka's effort was a controversial one, with Spain convinced the ball went out of play in the build-up.
During the brief period when Costa Rica led, Spain were on their way out of the tournament. Instead, though, they entered added time knowing they held a goal difference advantage over Germany which would see them through.
It is the second successive tournament in which Germany have fallen at the first hurdle. The 2014 champions were beaten twice in the 2018 group stage, with Mexico and South Korea securing victories to send them home.
This time, though, the damage was done before the final game. Germany missed chances during a 2-1 defeat against Japan, and their draw with Spain meant they went into their final game knowing their fate depended on the outcome elsewhere.
Japan will take on Croatia in the last 16, with the 2018 World Cup finalists surviving a number of scares before earning the point they needed against Belgium earlier in the day. Spain, meanwhile, will face Morocco after the African nation beat Canada to top their group.