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 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.
19 - There have been 19 penalties taken at the 2018 World Cup , more than in any other edition in the history of the competition. VAR . June 25, 2018
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. 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.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.