Germany appeared on the verge of making a sensational exit after Adam Szalai fired Hungary into the lead in the 11th minute at the Allianz Arena.
Kai Havertz handed Germany a fighting chance in the second half after pulling back an equaliser, but Hungary restored their lead within minutes of kick-off.
Manuel Neuer came charging off his line and was caught out by Hungary's immediate long ball forward straight from kick-off.
And Andras Schafer reached the ball before the Bayern Munich star as he fired a header into the back of the Germany net.
However, Leon Goretzka pulled back the all-important equaliser for Germany in the 84th minute to ensure Joachim Low's side progressed to the next stage of the competition.
Germany's 2-2 draw with Hungary secured a second-place finish for the 2014 World Cup champions.
Gareth Southgate's England side will now play Germany in the last 16 at Wembley on 29th June.
Meanwhile, France and Portugal played out an entertaining 2-2 draw at the Puskas Arena in Budapest, Hungary.
Cristiano Ronaldo fired Portugal into the lead in the first half from the spot-kick before a controversial France penalty ahead of half-time.
Karim Benzema stepped up and converted from the spot-kick as the 2018 World Cup champions pulled back an equaliser.
The Real Madrid striker completed his brace early into the second half as France took the lead against Portugal.
However, Ronaldo once again scored a penalty to equal former Iran striker Ali Daei's all-time international goalscoring record (109).
A draw against Portugal secured the top spot of Group F for France, who will now play Switzerland on 28th June at the National Arena in Bucharest, Romania.
Portugal, on the other hand, finished third and will now face Belgium at the Estadio La Cartuja on 27th June.
Featured Image Credit: PA
- Portugal vs Switzerland referee: Who are the match officials for the 2022 World Cup round of 16 clash?
- Germany are out of the World Cup after a pulsating night of football
- Kylian Mbappe Hits Out At France Football President Over Euro 2020 Penalty Miss Claim
- Germany And Portugal Play Out The Best Game Of Euro 2020 So Far