France needed a second-half equalizer from Antoine Griezmann to avoid the biggest upset of the tournament.
Hungary, playing in front of a raucous crowd yet again at the European Championship, held the World Cup champions to a 1-1 draw on Saturday.
Hungary's fans went wild when Attila Fiola gave the home team the lead.
Latching onto the ball after Roland Sallai won a header down the left flank, Fiola burst into the penalty area and held off defender Raphael Varane before clipping the ball into the bottom corner.
Germany's Kai Havertz, centre, celebrates after scoring his side's opening goal during the Euro 2020 soccer championship group F match between Portugal and Germany at the football arena stadium in Munich, Saturday. (Image: AP)
After Kylian Mbappe and Karim Benzema wasted chances, Griezmann scored in the 66th minute to dampen the spirit of a crowd which gave Hungary unwavering support throughout the Group F match.
It was Griezmann's 38th goal for France, moving him three behind third-place Michel Platini on the national team's scoring list, and he did a little celebratory dance in front of the blue-shirted fans.
Germany stuns Portugal
Germany finally clicked into gear at the European Championship, with a little help from defending champion Portugal.
The Portuguese became the first team to score two own-goals in one game at the continental tournament, giving the Germans a 4-2 victory on Saturday and ending fears of another group-stage exit.
Cristiano Ronaldo put Portugal in the lead in the 15th minute against the run of play. It was his first goal against Germany and his third at Euro 2020. It also extended his all-time tournament record to 12 goals.
But defenders Rúben Dias and Raphaël Guerreiro gave Germany the lead before halftime by scoring into their own net.
Kai Havertz and Robin Gosens then got two more for Germany early in the second half — becoming the first players within the squad to score at a European Championship.
“It's magic,” said Gosens, who was playing in his ninth game for Germany.
Diogo Jota got one back for Portugal in the 67th after Ronaldo acrobatically saved a free kick from going out.
Both Portugal and Germany now have three points in Group F, one behind current World Cup champion France.