Portugal edged closer to the Euro 2012 quarter-finals after a hard-fought win against Denmark in Lviv.

Portugal lost their opening Group B game against Germany on Saturday but goals from Pepe, Helder Postiga and substitute Silvestre Varela secured a 3-2 win for Paulo Bento's side.

Both coaches named unchanged sides from their opening games and it was Portugal who started brightest, with Cristiano Ronaldo and Nani a constant threat from either flank.

The Real Madrid forward wasted a good chance early on after he mis-hit his shot when well-placed on the edge of the area.

But Portugal took the lead after 25 minutes when Pepe headed in at the near post after a well-worked corner from Joao Moutinho.

And the 2004 finalists doubled their advantage 10 minutes later after Helder Postiga tucked home Nani's cross at the near post.

Denmark rallied and nicked a goal back just before half-time when Arsenal striker Nicklas Bendtner scored his fifth goal in five games against Portugal.

Lars Jacobsen knocked the ball forward and Michael Krohn-Dehli beat the offside trap to head back across goal and leave Bendtner with an easy header into the empty net.

Ronaldo wasted two further chances after the break. First, Nani set him free down the left with a clear run on goal but his shot was tame and goalkeeper Stephan Andersen made the save easily.

The second chance saw Ronaldo once again played in by Nani but, with just the keeper to beat, he side-footed the ball three yards wide of the right-hand post.