Leon Goretzka scored late to keep Germany in the European Championship after a 2-2 draw against Hungary on Wednesday.
Jamal Musiala made an immediate impact after coming on in the 82nd minute, eluding three defenders to give Timo Werner room to shoot. Werner, who also came on as a substitute, was blocked but the rebound fell for Goretzka, who shot past goalkeeper Péter Gulácsi in the 84th.
It had looked like Ádám Szalai was going to drag his team into the round of 16. The Hungary captain scored one goal early against the run of play and set up András Schäfer to make it 2-1 right after Kai Havertz had equalized for Germany.
Germany made the better start but was caught out early yet again in the tournament when Szalai met Roland Sallai’s cross with a flying header on a counterattack in the 11th.
Germany struggled against Hungary’s defensive 5-3-2 formation and was further hampered by heavy rain from a thundershower in the first half.
The home team also seemed to miss Thomas Müller’s unpredictability. Müller was on the bench because of a knee injury sustained in the 4-2 win over Portugal. Leroy Sané started in his place, the only change Joachim Löw made from the teams that started both previous games.
The home team had to wait till the 66th when the normally excellent Gulácsi failed to punch away Toni Koos’ free-kick. Mats Hummels headed the ball forward and Havertz made sure from close range.
Celebrations were cut short, however, as Hungary replied immediately when Szalai played in Schäfer to head the ball past Manuel Neuer.
It would have been enough to send Hungary through to the next round at Germany’s expense, but Löw’s substitutes rescued the game and kept him in a job. Löw is stepping down after the tournament.
Germany finished second in the group with four points and will next face England at Wembley Stadium on Tuesday.
Portugal drew with France 2-2 in the other group game and both have progressed, while Hungary finished last with two points and has been eliminated.
Before kickoff, a person with a rainbow flag ran onto the field and held it up in front of the Hungary team as the country’s national anthem was being played. The person was quickly tackled by stewards and pinned to the ground, and then led away to cheers and applause.
The build-up to the match had been overshadowed by a spat over the Munich city’s council’s request to illuminate the stadium in rainbow colors. UEFA refused on the grounds that it was a political statement directly addressed against Hungary.
Many German fans carried small rainbow flags that were distributed by activists before the game.