In a sensational tournament twist, they took the lead after just 11 minutes, much to the surprise of Joachim Low's men.
A superb breakaway saw Adam Szalai head home a pinpoint cross, stunning the home crowd.
The Germans perilously pursued a crucial equaliser for the remainder of the half, but were somewhat underwhelming in their efforts.
Matthias Ginter squandered an invaluable opportunity from close range, but was unable to trouble Peter Gulacsi as the resolute Hungarians went into the break a goal ahead.
Despite the best efforts of Marco Rossi's men they were unable to hold on to their lead as Kai Havertz levelled for Germany midway through the second half.
An incredible turn of events then saw Hungary regain their lead just two minutes later as Andras Schafer tucked away his shot past Manuel Neuer.
Nevertheless, Germany found yet another equaliser with just six minutes of normal time to play as Leon Goretzka scored his side's second.
After a valiant fight throughout the tournament for the Hungarians, their journey came to a cruel end with Germany securing the group's second spot.
Superb score draw separates France and Portugal
The first half of the match told a tale of two penalties, as both sides battled for Group F supremacy.
Portugal were presented with a crucial opportunity to take the lead when Hugo Lloris was penalised for colliding with Danilo in the French box.
In trademark fashion, Ronaldo put his country ahead from the spot - outwitting the goalkeeper with his fourth goal of the group stages.
As France fearlessly fought for a foothold in the game, they were awarded a penalty of their own on the stroke of half-time, under somewhat controversial circumstances.
A lengthy VAR check punished Nelson Semedo for a foul on Kylian Mbappe despite impassioned protests from the Portuguese players.
Breaking a major tournament goalscoring duck of more than seven years, Benzema scored the equaliser, leaving the sides level at the break.
After so long without a goal, Benzema soon scored his second just minutes after the restart - latching on to an immaculate pass from Paul Pogba to fire past Rui Patricio and put the French in front.
Another dramatic turn in the match saw Portugal awarded their second penalty of the evening when Jules Kounde carelessly handled a Ronaldo cross in the area.
With his 109th international goal, he brought the game level once more with yet another composed finish.
Pogba came agonisingly close to grabbing a third for Les Bleus but his speculative strike was pushed onto the post by Patricio, who kept out Griezmann's rebound.
In the end, the points were shared between the two sides, as they both ensured their qualification to the knockout stages.
Stat of the day
As per OptaJoe, Portugal vs France is the first game in the history of the European Championships to see three penalties scored (excluding shootouts).
A first placed finish for France will see them play Switzerland at 8pm on Monday at the National Arena in Bucharest.
Results going in Germany's favour means an age-old rivalry will be reignited as they travel to Wembley Stadium for a monumental clash with England in London.
The two sides will meet on Tuesday at 5pm, and the stakes could not be higher.
Third place for Portugal means they'll travel to Seville for a mouthwatering fixture against Belgium at the La Cartuja Stadium, with the game set to commence at 8pm.