Portugal played a tight 1-1 draw against Iran and progressed to the knockout round even as Ronaldo missed a penalty.
Portugal advanced to the World Cup round of 16 behind Spain from Group B after Ricardo Quaresma's stunning strike on the stroke of halftime was cancelled out by a dramatic stoppage-time penalty by Iran's Karim Ansarifard on Monday.
Portugal finished tied on five points with Spain, who drew 2-2 against Morocco to top the group by scoring more goals, and set up a second round clash with Group A toppers Uruguay in Sochi on Saturday.
Making his World Cup debut at the age of 34, Quaresma played a one-two with Adrien Silva to cut in from the right flank and curled the ball past the outstretched hands of goalkeeper Alireza Beiranvand with the outside of his boot.
Iran were awarded a penalty in stoppage time after Paraguayan referee Enrique Caceres used the video assistant referee (VAR) system to rule that Portugal's Cedric Soares had handled the ball in the box.
Ansarifard converted the penalty to make it 1-1, pushing Portugal to second spot in the group behind Spain.
Portugal were left to rue a missed penalty by Cristiano Ronaldo in the 51st minute after Beiranvand pulled off a heroic save to deny the European champions a 2-0 lead.
Caceres consulted with VAR to award the penalty for Morteza Pouraliganji's foul on Ronaldo amid vociferous protests from the Iranians and their numerous supporters at the Mordovia Arena.
The Real Madrid forward, however, failed to convert, also losing the chance to tie England's Harry Kane at the top of the scorers' list on five goals.
Iran, needing a win to have any realistic chance of advancing to the knockouts for the first time, were well organised at the back and defended stoically but did not have enough men going forward.
Carlos Queiroz's men relied mostly on counter attacks, and while forward Sardar Azmoun showed plenty of glimpses of his talent, it was not enough to deny the Portuguese.
Portugal had faced a lot of criticism for their lacklustre display and inability to hold possession in their 1-0 win against Morocco but they appeared determined to set that right against the Asian powerhouse.
Spain will meet hosts Russia at Moscow's Luzhniki Stadium on Sunday.