Spain have finished ahead of Portugal to advance as top qualifiers in Group B at the Fifa World Cup after both sides finished with dramatic draws in group play.
Portugal conceded a late penalty to draw 1-1 with Iran while Spain needed a late goal to avoid a shock loss to Morocco.
Iran had a chance to knock out Portugal with a late attempt on goal which went just wide.
Earlier in the game Cristiano Ronaldo missed a penalty for Portugal and was shown a yellow card after a lengthy VAR review for a possible red card.
Spain will face hosts Russia in the second round in Moscow while Portugal will play Uruguay.