Mehdi Taremi wasted a gilt-edged chance after Karim Ansarifard's penalty had thrown Iran a lifeline, but Portugal survived with a 1-1 draw to make the World Cup last 16 despite Cristiano Ronaldo's missed spot-kick in a match dominated by VAR.
The usually prolific Ronaldo was off target with a 53rd-minute penalty, awarded after a video-assisted review, as Portugal failed to build on Ricardo Quaresma's first-half stunner in the crucial Group B contest.
That miss from Ronaldo, who was perhaps fortunate not to see red for another VAR check after swinging an arm into the face of Morteza Pouraliganji, was punished when Cedric Soares was pinged for handball after referee Enrique Caceres again went to his video monitor.
Unlike Ronaldo, Ansarifard made no mistake with a powerful finish into the roof of the net to set up a grandstand finish in Saransk.
But Taremi fluffed his lines in the dying embers, firing into the side-netting from close range as Portugal held out for a crucial point.
It means the European champions are into the last 16 - where they face Uruguay - in second place, behind Spain – who themselves secured a dramatic 2-2 draw with Morocco – only on goals scored, while Iran settle for third with four points.
Predictably it was Ronaldo who had the first chance, the superstar forward cutting in from the left before lashing a powerful strike goalwards that Alireza Beiranvand held onto at the second attempt.
Iran responded well and Alireza Jahanbakhsh led a swift counter-attack before sliding a pass to Vahid Amiri, who dragged his first-time effort wide.
Ronaldo appealed for a penalty soon after when his free-kick clipped Sardar Azmoun's elbow, although replays suggest it would have been a harsh decision.
Jahanbakhsh was proving Iran's greatest threat and Rui Patricio had to be alert to deny the AZ winger an assist with a free-kick that Saeid Ezatolahi turned towards goal, but it would be Quaresma's piece of magic that broke the deadlock.
Having combined with Adrien Silva, Quaresma let rip with a wonderful outside-of-the-boot effort that looped over Beiranvand into the top-left corner.
34y 272d - Ricardo Quaresma is the oldest player to score on his first World Cup start (34 years, 272 days) since Yahya Golmohammadi for Iran against Mexico in 2006 (35 years, 84 days). Trivela. #IRNPOR #POR #WorldCup pic.twitter.com/LxL8DI0M84— OptaJoe (@OptaJoe) June 25, 2018
Referee Caceres appeared to have missed Ezatolahi's blatant foul on Ronaldo following the restart, but VAR again took centre stage when the official reviewed, and then overturned, his decision.
Ronaldo did not make Iran pay, though, failing to direct his low effort far enough to the right, enabling Beiranvand to get down and make a fine stop.
Azmoun tested the referee's resolve again when he went down under pressure from Jose Fonte, but Caceres rightly dismissed the striker's appeals for a penalty.
There was more VAR drama late on, however. After using his visual aid to conclude that Ronaldo's challenge on Pouraliganji was only worth a booking, Caceres used the system once more to determine that Cedric's handball from Azmoun's header had been intentional.
Ansarifard duly converted high to his right to give Iran hope, but Taremi was unable to complete the miracle turnaround as Iran ultimately fell at the first hurdle.
Key Opta stats:
- Portugal have progressed from the group stage of the World Cup for the fourth time in their history (also 1966, 2006 and 2010).
- Iran have been eliminated from the group stage at the World Cup in all five tournaments they have competed in (1978, 1998, 2006, 2014 and 2018).
- Both of Iran's goals at the 2018 World Cup were scored in injury time (94:06 against Morocco, 92:48 against Portugal).
- Portugal's Ricardo Quaresma (34y 272d) is the oldest player to score on his first World Cup start since Yahya Golmohammadi (35y 84d), who did so for Iran in 2006 against Mexico.
- Two of Cristiano Ronaldo's three penalties at the World Cup for Portugal have been against Iran – he scored in 2006 but saw his effort saved in this game.
- Ronaldo has a 50 per cent penalty success rate in major tournaments for Portugal, scoring two (against Iran and Spain at the World Cups in 2006 and 2018 respectively) but also failing with two (against Austria at Euro 2016 and Iran today).
- Iran remain winless in eight World Cup matches against European opposition (D2 L6).