A video replay in injury time gave Spain the goal it needed to win Group B at the World Cup.
Spain substitute Iago Aspas scored the late equalizer Monday in a 2-2 draw with Morocco. His clever deflection off a cross from Dani Carvajal was initially disallowed for offside, but the video assistant referee overruled the call at Kaliningrad Stadium.
Another substitute, Morocco forward Youssef En Nesyri, headed in a goal in the 81st minute to give already-eliminated Morocco hope of a victory.
Earlier, a mix-up by Andres Iniesta and Sergio Ramos gifted Morocco its first goal of the World Cup. Iniesta quickly made amends by setting up Isco at the other end to bring Spain level at halftime.
With Portugal also drawing with Iran, Spain progressed as group winner because it scored more goals.