Silvestre Varela finds the late finish to get Portugal and Cristiano Ronaldo out of jail against Denmark

Denmark 2 Portugal 3

It was Silvestre Varela who saved Cristiano Ronaldo's bacon yesterday in Lviv. The Porto winger, just two years into a stuttering international career, came off the bench to seize a late victory for Portugal over Denmark and preserve their hopes of progressing after Ronaldo had wasted a couple of opportunities to kill off the game.

Before Varela's 87th-minute goal it had been an infuriating game. Portugal had gone into a deserved 2-0 lead before allowing Denmark back into the game. Ronaldo, uncharacteristically, had missed two good chances to make it 3-1 before Nicklas Bendtner, for seven painful minutes, seemed to have snatched two points from them.

"The equaliser was unjust," said a relieved but proud Portuguese coach Paulo Bento afterwards, "but we didn't bow our heads. We showed character and got the winner we deserved."

Bento's Danish counterpart Morten Olsen was just as pleased with his own players. "It's a horrible feeling to concede so close to the end and end up losing the game," he said. "I was proud of the way we played against the Netherlands, but in a sense I'm prouder here of our second-half performance. We merited a point."

It was a testament to Denmark's effort that the most talented players were all wearing white as Portugal eased into the game. Nani was dangerous while Joao Moutinho's delivery asked questions of the Danish defence. Eventually on 25 minutes Moutinho's free-kick was turned behind for a corner, and from that he whipped the ball in towards Pepe, who headed Portugal 1-0 up.

Portugal were emboldened by their goal and 11 minutes after scoring their first they had a deserved second. A move which started on the left switched sides and from there Nani slid in a precise pass to the near post. Helder Postiga moved in front of centre-back Simon Kjaer and struck the ball high past Stephan Andersen.

This tournament has seen very few teams give up on games, though, and Denmark refused to do so here. A very clever move four minutes from half-time brought them back into the game. Jakob Poulsen, on for the injured Niki Zimling, swung in a cross from deep to the far post. Michael Krohn-Dehli pulled away and headed back across goal where an unmarked Bendtner nodded easily in.

At the start of the second half Ronaldo had the chance, not for the last time, to put Portugal 3-1 up. Postiga played him through but Andersen was quickly out and blocked on the edge of the box.

It might be unfair to call this Denmark side lucky, but situations were breaking in their favour. Dennis Rommedahl went off injured but his replacement, Tobias Mikkelsen, helped to bring a threat where one had been missing. He shuffled down the right and forced Rui Patricio to save his excellent cross before midfielder William Kvist's perfectly-struck volley flew narrowly over, with Patricio helpless.

With new energy, Eriksen started to shuffle past tackles in midfield, while Bendtner cut in from the right and whipped a shot just wide. And if Denmark feared their moment had passed, they were newly inspired with 12 minutes to go.

Nani, Portugal's best player, slid a marvellous pass through to Ronaldo, who was not. The world's most relentless goalscorer, one-on-one with Andersen, dragged his shot well wide. It was not the easiest chance of the tournament but given the context, and the quality of the forward, it might have been the worst miss.

This, clearly, was Denmark's great chance and two minutes later the inevitable equaliser came. Lars Jacobsen was gifted time and space to swing in a cross to the far post where Bendtner's header was powerful enough to squeeze between the post and Patricio's hand.

For seven minutes it felt like a harsh but fair judgement on Portuguese sloppiness: for those minutes it looked as if Ronaldo's side would face the Dutch with just one point. Enter Varela. A cross fell to the substitute in the box and after missing the ball with a wild swing of his left, he pivoted and smacked it past Andersen with a wild swing of his right. Portugal had taken their second chance.

Man of the match Nani.

Match rating 8/10.

Referee C Thomson (Scot).

Attendance 34,915.