In 1860 , Spain occupied northern Morocco and ushered in a half century of trade rivalry among European powers that saw Morocco 's sovereignty steadily erode ; in 1912 , the French imposed a protectorate over the country .