Iran equalised late on after Paraguayan referee Enrique Caceres used the video assistant referee (VAR) system to rule that Portugal's Cedric Soares had handled the ball in the box.
Fernando Hierro's Spain, the 2010 world champions, will play Russian Federation in the next round in Moscow on Sunday while European champions Portugal face Uruguay in Sochi the previous day.
Spain will next meet hosts Russian Federation at Moscow's Luzhniki Stadium on Sunday.
Eligible for the knockout stage are Spain, Portugal and Iran. The whole team should be commended for this World Cup.
Portugal's chances for more goals came early in the second half, when Ronaldo went down under a challenge by Ezatolahi.
Man of the match Quaresma praised his side's determination and said he was eager for the mouth-watering prospect of a last 16 encounter with twice World Cup winners Uruguay.
"We know it is going to be a tough match, always when you play against teams who are eliminated you don't know what they are going to do - it could be a big surprise".
"Now we have to continue with this mindset of winning and wait for the next match".
Iran vs. Portugal, June 25, 2 p.m. "If we play quickly across the pitch the chances will come".
"We can't take anything for granted, we have to use our skills and our qualities and that is what is most important going into the match".
Portugal had faced a lot of criticism for their lacklustre display and inability to hold possession in their 1-0 win against Morocco but they appeared determined to set that right against the Asian powerhouse.
They dominated possession, playing nearly three times the number of passes than their Asian opponents, and were more intent on creating chances through the midfield rather than just directing long balls towards Ronaldo.
"We have to force ourselves to find something to fight for so we can compete in the best possible psychological condition", he said.