Christian Eriksen came close for the Danes with five minutes on the clock, but he miscued when he might have done better.
However, it was Portugal who were ahead moments later when Pepe thumped his header in at the near post from Nani's corner.
Cristiano Ronaldo came close soon after, but he scuffed his effort wide from the edge of the box.
Their lead was doubled on 36 minutes as Helder Postiga fired in at the near post from Nani's low cross.
Despite Portugal's dominance in the first half, Denmark were handed a route back into the match five minutes before the break when Nicklas Bendtner headed in at the far post.
Ronaldo had a golden opportunity to stretch his team's lead at the start of the second half, but he could only shoot at Danish goalkeeper Stephan Andersen.
Following William Kvist's wayward volley for Denmark, Ronaldo wasted another glorious chance when he fired at Andersen again with only the keeper to beat.
Portugal looked to have been punished for their poor finishing when Bendtner headed his side level with 10 minutes to play.
However, substitute Silvestre Varela sealed an entertaining win with three minutes to play thanks to a powerful finish inside the area.