Cristiano Ronaldo finally found his magic touch on the way to making European Championship history, scoring twice to single-handedly salvage Portugal a place in the Euro 2016 knockout stages after a thrilling 3-3 draw with Hungary.
Much discussed in the build-up to the final Group F encounter in Lyon on Wednesday - having blasted Iceland's "small mentality" and then missed a penalty in the goalless draw with Austria - the Real Madrid superstar was already at the centre of attention well before kick-off - even more so after a video emerged of him throwing a television reporter's microphone into a lake earlier in the day.
By being named in Fernando Santos' starting XI, the 31-year-old completed a record 17th appearance in the competition, and his first strike on the night made him the only player to score in four separate Euros.
That effort, a brilliant flick with his trailing foot, hauled Portugal level after Balazs Dzsudzsak's deflected free-kick had given Bernd Storck's team the lead in a pulsating affair.
Earlier, in the first half, Zoltan Gera and Nani had exchanged goals to send the teams in level at 1-1.
Another deflected Dzsudzsak strike then put Hungary in control once again in the 47th minute, before Ronaldo finally took centre stage.
The Portugal captain latched on to Joao Mario's ball to produce his landmark, record-breaking finish before thumping a header home just past the hour mark to seal 3-3 draw.
That saw Portugal finish third in the group, setting up a meeting with Croatia in Lens on Saturday.
Hungary, meanwhile - for whom Akos Elek was denied a winner by the post - advance as section winners.
On a night when he was always likely to be the headline attraction, Ronaldo's frustration - which had been building throughout the tournament - was evident as early as the eighth minute.
When Nani failed to pick him out at the back post after hurtling down the left wing towards the byline, the captain wheeled away and made no effort to hide his displeasure.
His mood worsened 11 minutes later when a brilliant strike from Gera put Hungary ahead.
Headers from Ronaldo and Nani were not enough to clear away a corner, with Gera controlling the ball on his chest before driving a venomous half-volley low to Portugal goalkeeper Rui Patricio's left.
Elek could have doubled Hungary's lead when a tackle on Dzsudzsak resulted in a kind break of the ball, but Rui Patricio rushed off his line to make an important block.
Gabor Kiraly scurried across his line to stop a 30-yard free-kick from Ronaldo bouncing into the bottom-right corner, but the Hungary goalkeeper was beaten three minutes before half-time.
Ronaldo threaded a brilliant pass in behind the defence for Nani, who lashed home a powerful finish at the near post.
That gave Portugal a boost, but they found themselves behind again two minutes after the restart when Dzsudzsak's free-kick deflected off Andre Gomes and beat Rui Patricio.
Once again, though, Ronaldo came to the rescue. He brilliantly used his trailing leg to flick a cross from Joao Mario behind Adam Lang and into the far corner.
Hungary's resolve still was not broken and, after seeing his free-kick blocked by the wall, Dzsudzsak collected the rebound and picked out the far corner of the net to restore his side's shock lead - with the help of a deflection off Nani.
As things stood at that stage, Portugal were heading out, but in the 62nd minute that changed again.
Ronaldo - now in full stride - got away from Roland Juhasz to head substitute Ricardo Quaresma's left-wing cross into the net.
The topsy-turvy second period continued when Gergo Lovrencsics picked out Elek in the box, but the midfielder's first-time strike crashed back off the post.
And so Ronaldo's double proved enough to send Portugal through, although in the end that came as the third-placed side in Group F after Iceland's late winner in a 2-1 victory over Austria ensured the Nordic nation of the runner-up spot.