Portugal advanced to the World Cup round of 16 behind Spain from Group B after a Ricardo Quaresma strike was cancelled out by a stoppage-time penalty by Iran's Karim Ansarifard after Cristiano Ronaldo had himself missed from the spot.
Iran finish with four points and are eliminated despite an encouraging performance, especially in the second half.
The Monday night 1-1 draw meant 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.
Portugal was left to rue a missed penalty by talisman and captain Ronaldo in the 53rd minute after goalkeeper Alireza Beiranvand pulled off a heroic save to deny them a 2-0 lead.
Spain will meet hosts Russia at Moscow's Luzhniki Stadium on Sunday.