Cristiano Ronaldo's 95th-minute header earned Portugal a dramatic 1-0 Group I Euro 2016 qualifying win in Denmark on Tuesday.
Last year's FIFA Ballon d'Or winner out-jumped Simon Kjaer to nod in substitute Ricardo Quaresma's cross and give Fernando Santos his first victory as Portugal coach.
Ronaldo had been below-par throughout the Copenhagen clash, perhaps due to a knee niggle that he carried into the contest.
But he showed his star quality with a last-gasp winner that will significantly raise the Portugal spirits that were dented by a 1-0 home loss to Albania in their first qualifier last month.
Portugal were the better side in the first half, but Michael Krohn-Dehli came closest to scoring, with the Denmark attacker striking the post from distance.
Denmark defender Nicolai Boilesen had to be taken off on a stretcher in the second half after an errant clearance from team-mate Daniel Agger struck him flush on the side of his head and appeared to knock him out.
And there was further pain for Denmark as Ronaldo's late goal - his 18th of the season for club and country and 51st at international level - saw them lose for the first time in their qualifying campaign.
Portugal coach Santos took his place on the bench after being granted an appeal hearing by the Court of Arbitration for Sport that temporarily lifted his eight-match reprimand for abusing match officials at this year's World Cup.
Santos, then in charge of Greece, will have liked what he saw early as Portugal kept Denmark goalkeeper Kasper Schmeichel busy.
Ronaldo was first to test him in the seventh minute, stinging the palms of the Leicester City man, before Portugal's talisman almost turned provider in a neat one-two with Danny.
Danny shot straight at Schmeichel, though, and Ronaldo then screwed wide from an acute angle in the 17th minute.
Denmark had appeals for a spot-kick turned down, despite Eliseu appearing to handle the ball in his own penalty area, while at the other end, Nani spurned three chances in six minutes - the best of which saw him head Ronaldo's firm cross over from close range.
The hosts nearly took the lead completely against the run of play, when in the 34th minute, Krohn-Dehli curled onto the right-hand post - with goalkeeper Rui Patricio beaten - from the edge of the penalty area.
Ronaldo should have given Portugal the lead in the 51st minute after Danny unselfishly squared to him.
But the Portugal star took a heavy first touch and then shot into the onrushing Schmeichel.
After play resumed following Boilesen's substitution, Krohn-Dehli shot wide for the hosts from the edge of the area.
Both sides struggled for rhythm in the second half and Ronaldo showed his frustration with a late challenge on Pierre Hojbjerg that earned him a yellow card in stoppage time.
Ronaldo's anger quickly turned to joy, though, as he nodded in from four yards to have the last laugh in the Danish capital.