Germany's draw means they will face England at Wembley Stadium on Tuesday.
Hungary looked to cause an upset when they opened the scoring on 11 minutes with an impressive diving header from captain Adam Szalai, who connected with Roland Sallai's superb whipped cross behind the German back line.
Germany's Kai Havertz bought his side a lifeline on 66 minutes when he scored his second goal of the tournament. The Chelsea midfielder headed the ball home into an empty net after a goalkeeping error from Hungary's Peter Gulacsi.
Germany midfielder Leon Goretzka levelled the match once more on 85 minutes to secure his side's place in the round of 16.
"We made mistakes but we fought, showed character," Germany coach Joachim Low said. "It was not for the faint-hearted. At the end, to come through this group was good and that was the aim.
"What matters is that we are through. Now we play with England and we can look forward to that match. It is an absolute highlight to play at Wembley against England. We will be a different team than tonight, I can promise you that."
The buildup to Wednesday's match was dominated by UEFA's decision to reject a request from the Munich City Council to light the Allianz Arena in rainbow colours.
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.
Rainbow flags outnumbered German flags when fans arrived to the match. Supporters were met at the exit of a local subway station by a host of volunteers from groups including Amnesty International, CSD Germany and S'AG Munich distributing rainbow flags.
Germany captain Neuer also showed support for the LGBTQ+ community by wearing a rainbow armband, as he did in his side's previous match against France.
UEFA said the rainbow symbol was not the reason rejecting the request to light up the stadium, but Hungary's presence at the game.
Information from the Associated Press and Reuters contributed to this report.