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.
Karim Ansarifard equalised with a stoppage time penalty awarded after a video review.
However, Portugal clung on to finish second in the group with five points behind Spain, who drew 2-2 with Morocco, on goals scored, and will meet Uruguay in the last 16.
Ronaldo had his penalty saved and could have seen red in an incident packed Group B match.
The Portugal superstar was seen telling cheeky Iran fans to keep the noise down as they sang outside his hotel ahead of the game.