Updated

Underperforming Portugal finally got a win. Underperforming Cristiano Ronaldo wasn't much help.

After a miserable run of four games without a victory and only one goal scored, the Portuguese came through with an 87th-minute goal from substitute Silvestre Varela to beat Denmark 3-2 in Group B of the European Championship.

"Those of us who don't play from the start must be ready to join in at any time and deliver what the manager wants," said Varela, who replaced Raul Meireles in the 84th.

All four teams in Group B can still advance to the quarterfinals. After Germany beat the Netherlands 2-1 in the late match, the three-time champions lead the group with six points while both Portugal and Denmark have three.

Varela scored the winner three minutes from the end, spinning on the ball and shooting from short range. It was Varela's first international goal in four appearances.

But the winning strike came late, and after several missed opportunities from Ronaldo.

"We should have killed the game off earlier," Portugal coach Paulo Bento said. "We had enough chances."

Portugal also got first-half goals from Pepe and Helder Postiga at the Lviv Arena, but the Danes replied with a pair of goals from Nicklas Bendtner. The Denmark striker found the target just before halftime and then made it 2-2 in the 80th.

"To lose in the last five minutes is very tough for us to take," Bendtner said. "We felt that one point at that stage was a very good result for us."

Ronaldo is Portugal's captain and easily its best player. And at Euro 2012, the team is looking to him to reproduce the kind of goal-rich form he showed at Real Madrid last season when he scored 60 goals.

But Ronaldo, facing a compact Danish defense that denied the Netherlands a goal in its opening win, didn't even take a shot until the 18th minute. That one flew wide, and the forward threw his arms in the air and apparently cursed at a divot in the pitch.

"Ronaldo is one of the best players in the world and is a very good captain and a very good leader," Pepe said. "I'm sure he will score soon."

His best chances — and most astounding misses — came in the second half. He broke through the Danish defense five minutes after the break and ran at goalkepeer Stephan Andersen, who dived sharply to his left to block the shot.

In the 78th, Ronaldo was guilty of another miss when he went face-to-face with Andersen but again shot wide. Ronaldo appeared embarrassed, looking to the sky and closing his eyes as the crowd's jeers rang in his ears.

He said he was angry with himself "because of the chances I had and because I could have done better."

Ronaldo was the team's top scorer in qualifying for the tournament, racking up seven goals. But after the final whistle Wednesday, while Pepe raised his arms and celebrated, Ronaldo crouched alone on the field, staring quietly at the turf.

"(Ronaldo) couldn't help us today with a goal," Pepe said, "but he helped to get us here today."

To complete a despondent appearance, Ronaldo ended the game with a yellow card in added time for tripping William Kvist.

"Lucky for us Ronaldo wasn't that sharp today," Andersen said. "But at the end of the day we lost 3-2, so I'm sure Cristiano is the one who has a smile on his face."

Overall, the Portuguese will be happy with the victory against a team they had beaten only once in their previous five meetings. They were in the same qualifying group for Euro 2012 and the 2010 World Cup, and Denmark finished at the top of the group both times.

___

Lineups:

Denmark: Stephan Andersen, Lars Jacobsen, Simon Kjaer, Daniel Agger, Simon Poulsen, William Kvist, Niki Zimling (Jakob Poulsen, 16), Dennis Rommedahl (Tobias Mikkelsen, 60), Christian Eriksen, Michael Krohn-Dehli (Lasse Schoene, 90), Nicklas Bendtner.

Portugal: Rui Patricio, Joao Pereira, Bruno Alves, Pepe, Fabo Coentrao, Raul Meireles (Silvestre Varela, 84), Miguel Veloso, Joao Moutinho, Nani (Rolando, 89), Helder Postiga (Nelson Oliveira, 64), Cristiano Ronaldo.