Portugal took a step toward the Euro 2012 quarter-finals after surviving a Denmark fight-back to win 3-2 in Group B on Wednesday.Denmark came into the contest full of confidence after upsetting the Netherlands 1-0 in their opening match on Saturday, while Portugal were faced with the possibility of an early exit following their defeat to Germany by the same score-line.

Real Madrid defender Pepe earned Portugal the lead with a near-post header from a corner in the 24th minute of the match in Lviv.

Paulo Bento's team made it 2-0 nine minutes before the half-time break, when Helder Postiga sided-footed home from close range.

Denmark gained a foothold in the contest when Michael Krohn-Dehli headed a ball back across the Portugal goal, with Arsenal forward Nicklas Bendtner nodding home to make it 2-1.

Portugal captain Cristiano Ronaldo had a chance to win the match for his team but shot wide when one-on-one with the goalkeeper in the 77th minute.

And just moments afterwards, Bendtner made Ronaldo pay for the mistake, evading his marker at the back post to net the equaliser with his second header of the match.

It looked like Denmark had done enough to earn a point, but an accomplished strike from substitute Silvestre Varela with four minutes remaining saw Portugal join their beaten opponents on three points.