Ronaldo scored off a free kick at an international tournament for the first time to get the draw. He gave Portugal the halftime lead off a strike from distance that was bobbled by Spain goalkeeper David De Gea and opened the scoring through the penalty spot.
Diego Costa had a brace for Spain and Nacho converted a long-range scorcher in the second half as well.
With this result, it now means Portugal and Spain are level on one point in Group B behind first-place Iran. Morocco is bottom of the Group with zero points.