
By the mid 1800s, at a time when the influence of Ottoman Empire was in decline, Europe was taking a great interest in Morocco. Algeciras Conference (1906) formalized France's special interest in the region (opposed by Germany). Treaty of Fez (1912) made Morocco a French protectorate, and Spain gained authority over Ifni (to the south) and Tétouan to the north.
In the 1920s the Rif Berbers of Morocco, under the leadership of Muhammad Abd el-Krim, rebelled against French and Spanish authority. The short lived Rif republic was crushed by a joint French/Spanish task force in 1926.

Mohammed V was succeeded by his son, Hasan II ibn Mohammed, on his death in 1961. Morocco became a constitutional monarchy in 1977.
When Spain withdrew from Spanish Sahara in 1976, Morocco claimed sovereignty in the north. When Muritania withdrew in 1979, Morocco occupied the whole region.
When Hassan II died in 1999 he was succeeded by his son Mohammed VI ibn al-Hassan.