That result would put Spain into the last 16 after Isco cancelled out a surprise opening strike from Morocco's Khalid Boutaib.
Spain are on course to finish second in the group behind Portugal, who led Iran 1-0 at halftime. Morocco have been eliminated.