Germany will face England in the last 16 of Euro 2020 after twice coming from behind to knock battling Hungary out of the tournament.
An outstanding header by Adam Szalai, who plays his club football in Germany for Mainz, had given Hungary a shock lead in Munich.
Andras Schafer thought he had won it for the Hungarians with a header – 90 seconds after Kai Havertz had equalised – before substitute Leon Goretzka made it 2-2 six minutes from the end.
It means Germany finish second in Group F and will now meet Gareth Southgate’s England at Wembley in a hugely anticipated last-16 match next Tuesday (17:00 BST).
Germany fans wear rainbow colours at Hungary game
Relive the finale to Group F, plus reaction
Why I don’t want this to be the end for Low – Klinsmann
Hungary suffer heartbreak
In an extraordinary match, Germany were minutes away from making an embarrassing early exit when midfielder Goretzka, on as a substitute, equalised in the 84th minute with a low finish from 16 yards to send Hungary out.
Few outside Hungary will have given Marco Rossi’s side any chance of advancing after losing 3-0 to holders Portugal in their opening group game.
But they followed up a gutsy 1-1 draw against world champions France with a disciplined performance to give the home fans in the Allianz Arena a scare.
They opened the scoring after Roland Sallai’s incredible long-range pass picked up his captain Szalai to beat Manuel Neuer with a diving header.
Chelsea’s Havertz equalised with a header following an error by goalkeeper Peter Gulacsi but Germany fans were still celebrating when Schafer’s brave header in front of Neuer, who had come rushing off his line, put Hungary back in front.
At that stage, Hungary were heading into the last 16 and Germany were set for an early exit before Bayern Munich’s Goretzka came to the rescue to break Hungarian hearts – and set up a mouth-watering match against England.
That match will revive memories of when the two nations met in the semi-finals of Euro 96 – Germany winning a penalty shootout at Wembley to deny the Three Lions a place in the final.