Silvestre Varela came off the bench to score an 87th-minute winner as Portugal beat Denmark 3-2 in a Euro 2012 thriller on Wednesday and put themselves right back in the Group B mix.

Portugal, beaten 1-0 by Germany in their opener, went ahead after 24 minutes when Pepe glanced in a header from a corner and doubled their lead in the 36th with simple finish by Helder Postiga from a low Nani cross.

Nicklas Bendtner pulled one back in the 41st minute and, after Cristiano Ronaldo had missed a glorious chance to make it 3-1, looked to have secured a point for the Danes when he headed his second after 80.

Varela had the final word, however, when, at the second attempt, he smashed in the winner three minutes after coming on.

Portugal and Denmark have three points, as do Germany, who take on pointless Netherlands in Kharkiv in the other Group B game later on Wednesday.

(Reporting by Mitch Phillips; editing by Ken Ferris)