- In 1904, the Entente Cordiale or the private agreements among the United Kingdom, Italy and France in 1904 made without consulting the sultan, had divided the Maghreb into spheres of influence, with France given Morocco.
- In Morocco, the young sultan Abdelaziz acceded in 1894 at the age of ten, and Europeans became the main advisors at the court, while local rulers became more and more independent from the sultan until the sultan was deposed in 1908 leading to the deterioration of Moroccan law and order under his successor, Abdelhafid, who abdicated in favour of his brother Yusef after signing the Treaty of Fez.
- By the Treaty of Fez (Arabic: معاهدة فاس), signed 30 March 1912, Sultan Abdelhafid made Morocco a French protectorate, resolving the Agadir Crisis of 1 July 1911.
- The Treaty authorized French military occupation of Morocco and control of its economic activities.
- It also denied the Makhzen direct contact with foreign nations and imposed French diplomatic representation on Morocco.
- The sultan was granted protection and his throne was made immune against the vagaries of time.
- As an ironical sequel, Sultan Abdelhafid was forced to abdicate to his younger brother Moulay Youssef only months after his signature of the ominous Treaty of Fés.
- Germany recognised the French protectorate in Morocco, receiving in return territories in the French Equatorial African colony of Middle Congo (now the Republic of the Congo), known as Neukamerun, became part of the German colony of Kamerun, part of German West Africa, for a brief time until it was captured by the allies in World War I.
- As part of the treaty, Germany ceded France a small area of territory to the south-east of Fort Lamy, now part of Chad.
- Spain also gained a zone of influence in Northern Morocco which became Spanish Morocco and gained a zone of influence in the Rif and the Cape Juby areas, where the sultan remained nominally the sovereign and was represented by a vice regent under the control of the Spanish high commission.
- The Treaty of Fez granted the concession for exploitation of the iron mines of Mount Uixan to the Spanish Rif Mines Company, which was also given permission to build a railroad to connect the mines with Melilla.
- The treaty was perceived as a betrayal by Moroccan nationalists and led to the 1912 Fez riots and the War of the Rif (1919–26) between the Spanish and the Moroccan Rif and the Jebala tribes. Their leader became Abd el-Krim, who, after driving back the Spanish, founded a short-lived nationalist Republic of the Rif.