The First Franco-Moroccan War consisted of a series of conflicts fought between France and its colonial administrators on one side, and the sultanate of Morocco on the other. The principal cause of war involved the retreat of Algerian resistance leader `Abd al-Qādir into Morocco following French victories over many of his tribal supporters in the French conquest of Algeria. The name of the conflict can be misleading however, seeing the first conflict between the two nations took place during the Larache expedition, after the Seven Years' War.
The Second Franco-Moroccan War took place in 1911, when Moroccan forces besieged the French-occupied city of Fez. Approximately one month later, French forces brought the siege to an end. On March 30, 1912, Sultan AbdelHafid signed the Treaty of Fez, formally ceding Moroccan sovereignty to France, which established a protectorate. On April 17, 1912, Moroccan infantrymen mutinied in the French garrison in Fez. The Moroccans were unable to take the city and were defeated by a French relief force. In late May 1912, Moroccan forces unsuccessfully attacked the enhanced French garrison at Fez.
Before the French colonization in the 19th century, parts of southern and western Algeria belonged to Morocco. In the 1930s and later in the 1950s, France had integrated into what was known as the Overseas Département of French Algeria, the areas of Tindouf and Bechar. When Morocco gained independence in 1956, it wanted to reassert sovereignty over these areas. In an effort to cut the support that the Front de Libération Nationale (FLN) was getting from Morocco, France offered to return those areas in exchange for Morocco stopping that support. King Mohammed V refused to make a deal with France behind the back of the "Algerian brothers", and agreed with the Algerian provisional government's nationalist leader Ferhat Abbas, that once Algeria gained its independence it would renegotiate the status of the Tindouf and Bechar areas.
However, immediately after Algeria's independence, and before his agreement with the Moroccan King Muhammad V could be formally ratified, the first Algerian provisional president Ferhat Abbas was purged from the FLN government by a military-backed coalition led by the first Algerian provisional president Ahmad Ben Bella. The last, bloody years of the FLN's rebellion had been fought essentially to prevent France from splitting off the Sahara regions from the emerging Algerian state, and thus neither Ben Bella nor the rest of the wartime FLN were inclined to give them up to Morocco when independence was achieved. The Algerians therefore recognized neither Morocco's historical nor its political claims. Instead, they perceived the Moroccan demands as an attempt to infringe the country's hard-won independence and pressure it when it was at its weakest. Algeria was still reeling from the enormous damage caused by its war against French colonialism, and the government scarcely held control over its entire territory - significantly, a Berber anti-FLN rebellion under the leadership of Hocine Aït Ahmed had recently flared up in the Kabyle mountains. Tension escalated, as neither side wanted to back down.
Skirmishes along the border eventually escalated into a full-blown confrontation, with intense fighting around the oasis towns of Tindouf and Figuig. The Algerian army, just formed from the guerrilla ranks of the FLN's Armé de Libération Nationale (ALN) was still geared towards asymmetric warfare, and had little high-powered equipment . They were still battle-ready and held tens of thousands of experienced veterans, and strengthening the armed forces had been a top priority for the military-dominated post-war government. On the other hand, while being modern, western-equipped Moroccan army was superior on the battlefield, it did not manage to penetrate into Algeria. The war stalemated with the intervention of the Organization of African Unity (OAU) and the Arab league and it was broken off after approximately three weeks. The OAU eventually managed to arrange a formal cease-fire on February 20, 1964. A peace agreement was then made after Arab League mediation, and a demilitarized zone instituted but hostilities simmered.