Ricardo Quaresma scored the winning penalty as Portugal beat Poland, 5-3, in a shootout to reach the semifinals of the European Championship on Thursday.

With the quarterfinal level at 1-1 after extra time, Quaresma fired his shot past Lukasz Fabianski to line up a match against either Wales or Belgium in Lyon on Wednesday.

Having previously scored an extra-time winner in the round of 16 against Croatia, Quaresma’s penalty sent Portugal into the semifinals for the fourth time in the last five European Championships.

Poland winger Jakub Blaszczykowski came into the match at the Stade Velodrome as his team’s top scorer. But he had a poor game and saw his penalty saved one-handed by Rui Patricio, allowing Quaresma to finish the job with the very next kick in front of a stand packed with Polish fans.

On a night when captain Cristiano Ronaldo turned in another disappointing performance, 18-year-old midfielder Renato Sanches stepped up to score Portugal’s equalizer in the first half. The teenager was his team’s main attacking threat for much of the game with his smart movement and passing, and took man-of-the-match honors in his first international start.

“It’s wonderful for the team, for me as well for scoring the goal,” he said. “People criticize us, but we don’t care because in the end we’re in the semis.”

Portugal’s last six games at European Championships have been drawn after 90 minutes in a run dating back to its loss to Spain on penalties in the 2012 semifinals.

Earlier, Poland striker Robert Lewandowski had put his team in front with the quickest goal of the tournament, scoring inside two minutes.

Portugal right-back Cedric Soares misjudged a cross-field ball, allowing Kamil Grosicki to break into space on the left flank and send in a low cross for Lewandowski to convert with a first-time shot.

Poland’s lead lasted until the 33rd minute, when Sanches lit up the game with an equalizer.

The youngster, who has just been signed by Bayern Munich, cut in from the right and passed to Nani, who sent it back immediately with a neat backheel. Sanches then unleashed a powerful shot from the edge of the area that took a deflection off Grzegorz Krychowiak on its way past the outstretched Fabianski.

Despite becoming the third-youngest scorer in European Championship history, Sanches played down his goal, calling it simply “a move that just turned out that way and I scored.” He also volunteered to take a penalty in the shootout and scored with a confident strike into the top-left corner.

The match might have been settled in regulation time if Ronaldo hadn’t missed a golden opportunity in the 85th minute. He beat the Polish offside trap with a perfectly timed run, but completely missed the ball as he tried to convert a bouncing pass from Joao Moutinho.

The Real Madrid star missed another good chance early in extra time when he failed to control the ball in front of goal. The errors meant he has yet to match Michel Platini’s all-time record at European Championships of nine goals. However, Ronaldo did score with Portugal’s opening penalty of the shootout.

After the game, Ronaldo threw away his captain’s armband in frustration.

Poland also had chances to win the game in the second half, notably when Patricio stopped a diving header from Lewandowski.

However, the Poles also came within centimeters of scoring an own-goal in the 81st when Pepe’s pass for Ronaldo was cut out by left-back Artur Jedrzejczyk, whose sliding challenge sent the ball narrowly wide of his own post.

Midfielder William Carvalho has started the last three games for Portugal but will miss the semifinal thanks to a second booking of the tournament.

Both teams face sanctions from UEFA for pyrotechnic use by their fans, while play was briefly stopped in extra time by a fan who ran onto the pitch before being overcome by police. He wore a green shirt and it was not immediately clear whether he was a fan of either team.