Niclas Fullkrug gave Germany a precious point against Spain as they fight for World Cup survival.
Germany's hopes of reaching the knockout phase had been given an unlikely lifeline earlier on Sunday when Costa Rica beat Japan when any other result would have meant defeat by Spain would send them out.
Hansi Flick's side still need to beat Costa Rica in their final Group E game and hope Japan do not spring a shock against Spain but at least they know their hopes of moving into the last 16 are intact after falling behind at Al Bayt Stadium.
Spain, who almost went ahead in the first half when keeper Manuel Neuer turned Dani Olmo's shot on to the bar, took the lead after 62 minutes when substitute Alvaro Morata applied a brilliant near-post flick to Jordi Alba's cross.
Germany pressed forward and Fullkrug gave them a point seven minutes from the end when he burst through and lashed an unstoppable finish high past Spain keeper Unai Simon.
Leroy Sane almost won it for Germany in the dying seconds but ran out of space as he raced through on goal and the ball was scrambled clear.
More follows
helpHow to play
Rate players out of 10 throughout or after the game. The rater will close 30 minutes after the final whistle.
Rating range key1 = Give it up10 = Pure perfection
Spain
Squad number23Player nameSimón
Squad number20Player nameCarvajal
Squad number16Player nameRodri
Squad number24Player nameLaporte
Squad number18Player nameAlba
Squad number9Player nameGavi
Squad number5Player nameBusquets
Squad number26Player namePedri
Squad number11Player nameF Torres
Squad number10Player nameAsensio
Squad number21Player nameOlmo
Squad number7Player nameMorata
Squad number8Player nameKoke
Squad number12Player nameNico Williams
Squad number14Player nameBalde
Germany
Squad number1Player nameNeuer
Squad number5Player nameKehrer
Squad number15Player nameSüle
Squad number2Player nameRüdiger
Squad number3Player nameRaum
Squad number6Player nameKimmich
Squad number8Player nameGoretzka
Squad number10Player nameGnabry
Squad number21Player nameGündogan
Squad number14Player nameMusiala
Squad number13Player nameMüller
Squad number9Player nameFüllkrug
Squad number16Player nameKlostermann
Squad number18Player nameHofmann
Squad number19Player nameSané
Squad number23Player nameSchlotterbeck
Line-ups
Spain
Formation 4-3-3
23Simón
20Carvajal16Rodri24Laporte18Alba
9Gavi5Busquets26Pedri
11F Torres10Asensio21Olmo
23Simón20Carvajal16Rodri24Laporte18AlbaSubstituted forBaldeat 82'minutes9GaviSubstituted forWilliams Arthuerat 66'minutes5BusquetsBooked at 44mins26Pedri11F TorresSubstituted forMorataat 54'minutes10AsensioSubstituted forKokeat 66'minutes21OlmoSubstitutes
1Sánchez2Azpilicueta3García4P Torres6Llorente7Morata8Koke12Williams Arthuer13Raya14Balde15Guillamón17Pino19Soler22Sarabia25Ansu FatiGermany
Formation 4-2-3-1
1Neuer
5Kehrer15Süle2Rüdiger3Raum
6Kimmich8Goretzka
10Gnabry21Gündogan14Musiala
13Müller
1Neuer5KehrerBooked at 37minsSubstituted forKlostermannat 70'minutes15Süle2Rüdiger3RaumSubstituted forSchlotterbeckat 87'minutes6KimmichBooked at 60mins8GoretzkaBooked at 58mins10GnabrySubstituted forHofmannat 85'minutes21GündoganSubstituted forSanéat 70'minutes14Musiala13MüllerSubstituted forFüllkrugat 70'minutesSubstitutes
4Ginter7Havertz9Füllkrug11Götze12Trapp16Klostermann17Brandt18Hofmann19Sané20Günter22ter Stegen23Schlotterbeck24Adeyemi25Bella-Kotchap26MoukokoReferee:Danny MakkelieAttendance:68,895Live Text
Match ends, Spain 1, Germany 1.
Second Half ends, Spain 1, Germany 1.
Corner, Germany. Conceded by Rodri.
Corner, Germany. Conceded by Daniel Carvajal.
Foul by Dani Olmo (Spain).
Niklas Süle (Germany) wins a free kick in the defensive half.
Corner, Spain. Conceded by Nico Schlotterbeck.
Substitution, Germany. Nico Schlotterbeck replaces David Raum.
Substitution, Germany. Jonas Hofmann replaces Serge Gnabry.
Goal! Spain 1, Germany 1. Niclas Füllkrug (Germany) right footed shot from the centre of the box to the top left corner. Assisted by Jamal Musiala.
Substitution, Spain. Alejandro Balde replaces Jordi Alba.
Corner, Germany. Conceded by Dani Olmo.
Attempt blocked. Joshua Kimmich (Germany) right footed shot from outside the box is blocked.
Niclas Füllkrug (Germany) wins a free kick in the attacking half.
Offside, Spain. Koke tries a through ball, but Álvaro Morata is caught offside.
Attempt missed. Niclas Füllkrug (Germany) header from the centre of the box is high and wide to the right. Assisted by David Raum with a cross following a corner.
Corner, Germany. Conceded by Rodri.
Attempt blocked. Serge Gnabry (Germany) right footed shot from the left side of the box is blocked. Assisted by David Raum.
Attempt saved. Jamal Musiala (Germany) right footed shot from the right side of the box is saved in the top centre of the goal. Assisted by Leroy Sané with a through ball.
Get the latest results and goal notifications for any team at the Fifa World Cup by downloading the BBC Sport app: Appleexternal-link - Androidexternal-link - Amazonexternal-link
Get your daily dose of Fifa World Cup reaction, debate & analysis with World Cup Daily on BBC Sounds