It was the Hungarians – who had already qualified for the last 16 – who took the initiative in the first half.
Fielding a team with no less than five changes from their last starting XI, it was an 18th-minute cross from the right which found Zoltan Gera whose left-footed kick sent the ball past ‘keeper Rui Patricio.
Portugal dominated possession in the first half and had the greater number of shots on goal, but Fernando Santos's men looked far from assured at Parc Olympique Lyonnais.
However, it only took a little touch of class from Cristiano Ronaldo in the 42nd minute whose pass to Nani cut open the Hungarian defense. Nani duly finished on the left foot, sending the ball low and hard past 40-year-old Gabor Kiraly.
However, in the second half both teams tore up the script with a flurry of scores at either end in short succession. Hungary hit Portugal straight after the break with Balazs Dzsudzsak’s 47th-minute free kick coming off a Portugal defender to end up in the net, making it 2-1 to Bernd Storck's men.
But it was Real Madrid star Ronaldo who hit back shortly after. He latched on to a 50th minute cross from the right before burying it in the Hungarian net, leaving the sides level.
Hungary was not playing like a side which had already qualified. Five minutes later it was Dzsudzsak again. His initial free kick was blocked but he remained composed to control the rebound and launch a rocket past Patricio, giving the Hungarians a 3-2 lead.
There was to be one more twist in the tale. Ronaldo, having been reduced to apoplexy by Dzsudzsak's second score, banged home a 61st-minute header to leave the sides level at 3-3 apiece.
In Wednesday's other Group F match, Iceland snatched a late 2-1 win over Austria, with Arnor Traustason scoring in the 90th minute and sending them through to the last 16.