The French retained their protectorate over most of Morocco all the way until 1956, i.e. for 44 years.
On this day in 1912 the Moroccan sultan Abd al-Hafid signed the Treaty of Fez, giving the French a protectorate over Morocco. By doing this he also abdicated, leaving his younger brother Yusef to become the new sultan. The treaty was signed when there was already a ship in Rabat waiting to take him back to France. He died in Enghien-les-Bains near Paris 25 years later.
By signing the Treaty of Fez (named after a city in Morocco), the sultan ended the Second Morocco Crisis. This was an international crisis related to the distribution of colonies between the great powers. Namely, the German Empire was relatively weak in terms of overseas colonies and thus tried to gain some influence in Morocco, one of the few countries in Africa which had not yet been taken over by one of the great powers. In 1911 the Germans had sent the gunboat SMS Panther there as a form of “gunboat diplomacy” (the incident is sometimes called Panther’s jump).
However, it was the French who eventually asserted their rule over most of western Africa, including Morocco. The Germans received a part of the Congo (New Cameroon) as a sort of compensation. The French retained their protectorate over most of Morocco all the way until 1956, i.e. for 44 years.