Germany gave themselves hope of avoiding another embarrassing early World Cup exit when they snatched a 1-1 draw with Spain on Sunday with Niclas Fuellkrug firing home an 83rd minute equaliser on only his third appearance for his country.
The result leaves the four-time world champions facing a must-win match against Costa Rica on Thursday, and also means Spain have yet to book their passage out of Group E. Japan and Costa Rica could yet qualify too.
Germany looked to be in severe danger of repeating their group stage failure of 2018 in Russia when Alvato Morata, eight minutes after coming on from the bench, handed Spain the lead by neatly flicking in a cross from Jordi Alba in the 62nd minute.
A defeat against Spain after Germany's shock 2-1 opening loss to Japan would have left Hansi Flick's men facing a huge challenge to get into the knockout phase.
But in the 83rd minute they battled back into contention as Leroy Sane took advantage of a poor defensive clearance to feed Jamal Musiala who turned between two Spain defenders, with the ball falling to Fuellkrug who fired high into the net.
The Werder Bremen forward, who won his first cap earlier this month after a string of goals in the Bundesliga, had replaced Thomas Mueller 13 minutes earlier as Germany desperately sought an equaliser.
"We knew what the situation was, what was at stake," Flick told reporters, and he said Fuellkrug's equaliser might prove to be a turning point for Germany in Qatar.
"Things start to happen when you start to win, so maybe this will give us a boost and give us the self confidence to get goals," he said.
Spain coach Luis Enrique said he was left ruing his side's failure to hold on to their lead. "But after two matches we are in the top of the classification of the death group and I think that we have to be positive," he said.
The Spaniards had looked more relaxed from the start, cutting through Germany with their angled passing in the Al Bayt Stadium, about 50km (30 miles) north of Doha. Dani Olmo almost created an early breakthrough in the seventh minute but his shot was palmed onto the bar by Manuel Neuer.
Germany 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 Unai 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, 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.