- Zoltán Gera opens scoring for Hungary; Nani levels before half-time
- Balázs Dzsudzsák registers with two deflected goals after break
- Cristiano Ronaldo equalises twice, becoming first player to score in four UEFA EURO editions
- Ronaldo also makes record-breaking 17th appearance in final tournaments
- Hungary win Group F and face Group E runners-up in last 16; Portugal will meet Croatia
Portugal will join Group F winners Hungary in the round of 16 after Cristiano Ronaldo averted disaster with a historic double to earn his side third place in a pulsating 3-3 draw.
Making a record 17th UEFA EURO finals appearance, the Real Madrid forward had cut a frustrated figure in his first two outings, and his mood was hardly improved by the first goalscoring instalment of a frenetic match. Zoltán Gera delivered it, fizzing a low half-volley beyond Rui Patrício after collecting a half-cleared corner on his chest.
It was an excellent strike for a team already through, but Nani levelled close to half-time thanks to Ronaldo's exquisite, effortless through ball. With both defences looking vulnerable, an already thrilling game then became a spectacularly open one after the interval, Balázs Dzsudzsák firing Hungary back in front from a deflected free-kick.
Portugal were heading home again, until Ronaldo became the first player to score in four separate editions of this tournament – and with trademark panache, meeting João Mário's cross with a back-heeled flick. Still Hungary were not done, and it was Dzsudzsák who put them ahead once again another deflected effort.
The last word nevertheless belonged to Ronaldo, who rescued the Portuguese for a second time by nodding in. That made it five goals in 21 minutes, and, once the dust had settled, Portugal were facing a meeting with Croatia; Hungary will play the Group E runners-up on 25 June. Both sides will need to catch their breath first.
Man of the match: Cristiano Ronaldo (Portugal)
Did anyone actually believe that Ronaldo would leave UEFA EURO 2016 without finding the net? His travails in Portugal's opening two games merely redoubled his motivation to sparkle here, and he finally left his stamp on the tournament with a fine, crucial double. His two historic markers in this match will matter little for now, though – more importantly, Portugal are still alive in the finals and their talisman has arrived.
Portuguese newspaper O Record declared that it was 'Ketchup time' on their front page this morning, referencing Ronaldo's idea that once the goals start flowing they never stop. Prophetic headline, as these two teams played out the highest-scoring fixture at UEFA EURO 2016, with Ronaldo at the heart of the action. It was nourishing stuff – not just ketchup, but lashings of goulash and francesinha too.
Gera's still got it
Gábor Király has grabbed most of the headlines among the more senior contingent at UEFA EURO 2016, but the 40-year-old goalkeeper was upstaged by Zoltán Gera in Lyon. The Ferencváros veteran broke the deadlock for Hungary to take his international tally to 25 goals – and become the second oldest scorer at a UEFA European Championship aged 37 years and 61 days, with only Austria's Ivica Vastić out in front. What a wonderful effort it was too.
Portugal save their pride
A loss would have sent Portugal crashing out of the tournament after the group stage for the first time in their history. The Selecção das Quinas touched down in France with the record of having reached a final, three semis and two quarter-finals from their six previous visits – and they will be back in the knockout rounds after staving off what would have been a remarkable reverse. Coach Fernando Santos is backing them to get to the final, but his side cannot get too carried away after a trio of draws.
Team reporters' views from Stade de Lyon
UEFA.com team reporters
Matthew Watson-Broughton, Hungary (@UEFAcomMattWlB)
A dream start for Hungary by way of Gera's sweet half-volley, but you always felt Portugal would find a way back into the game and so it proved just before half-time, with Nani's crisp, low reverse shot foxing Király at his near-right post. Hungary captain Dzsudzsák then came to the party with his two deflected goals sandwiching a sumptuous back-heeled effort from Cristiano Ronaldo, and the Madrid forward equalised as Portugal threatened to overrun Bernd Storck's men. To their credit, Hungary weathered the storm and emerge with huge credit as well as a point, which maintains their unbeaten record in the tournament.
Joseph Walker, Portugal (@UEFAcomJoeW)
And that's a wrap. Breathless, brilliant entertainment. Where to begin? Well ... Portugal are through to the round of 16 – there's a start – but that doesn't even begin to come close to it. Portugal were in, they were out, but Ronaldo appeared when they most needed him to get them out of jail. He took the match by the scruff of the neck and got his side through, albeit by the skin of their teeth. Plenty for Santos to think about, with a lot of defensive fragility on show.