Portugal qualified for the round of 16 at the World Cup despite being held 1-1 by Iran in World Cup Group B on Monday after Cristiano Ronaldo missed a penalty.
The European champions, needing a draw to qualify, went ahead with a stunning Ricardo Quaresma goal in the 45th minute.
Ronaldo had a chance to extend the lead when he won a penalty in the 51st minute but Iran goalkeeper Alireza Beiranvand dived to his left to save his effort from the spot.
Meanwhile, Spain snatched a 2-2 draw against Morocco on Monday to qualify for the last 16 and take top spot in Group B ahead of Portugal on goals scored.
Morocco striker Khalid Boutaib gave the north African side a shock early lead but Isco levelled, blasting high into the net after a layoff from Andres Iniesta.
Morocco, already eliminated, struck again in the 81st minute when substitute Youssef En-Nesyri crashed in a header which looked set to inflict a first defeat on Spain since Euro 2016.
But substitute Iago Aspas levelled in stoppage-time after consultation from the video assistant referee (VAR), putting Spain top ahead of Portugal, who were held to a 1-1 draw by Iran.
Spain will play Russia in the last 16, while Portugal will take on Uruguay.