Germany gave themselves hope of avoiding another early World Cup exit when they snatched a 1-1 draw with Spain as substitute Niclas Fuellkrug fired home an 83rd-minute equaliser that cancelled out Alvaro Morata's opener.
The result leaves Germany facing a must-win match against Costa Rica in four days' time and also means Spain have yet to book their spot in the knockout phase of the tournament.
Germany were looking in danger of suffering another early exit from the World Cup, after being eliminated following the group stage in 2018, before Fuellkrug took advantage of Jamal Musiala's battling in the box to fire high into the net past Unai Simon in Spain's goal.
Morata, himself a substitute, had increased the jeopardy for the Germans when he neatly flicked in a cross by Jordi Alba in the 62nd minute.
The Spaniards looked more relaxed from the start, cutting through Germany with their angled passing, and Dani Olmo almost created an early breakthrough in the seventh minute but his shot was palmed onto the bar by Manuel Neuer.
Germany went into their encounter against Spain at the Al Bayt Stadium under immense pressure after suffering a shock defeat to Japan in their opening match.
Hanse Flick's men thought they had taken an unlikely lead in the 39th minute when defender Antonio Rudiger powered in a header from a Joshua Kimmich free kick, but the German celebrations were cut short as VAR quickly ruled that he was offside.
Spain goalkeeper Simon was forced into his first save in the 56th minute when the 2010 champions got into trouble trying to play out of defence, allowing Kimmich to shoot from just inside the penalty area but Simon saved impressively.
Spain top the standings with four points and now need only a draw in their final Group E game against Japan to progress. A win would send them through to the knockout round in first place.
Germany, who lost 2-1 in their opener against Japan, are bottom of the table on one point. They need to win against Costa Rica on Thursday and their hopes then depend on Japan losing. If Japan draw it would come down to goal difference or goals scored by Germany and Japan.