The Royal Moroccan Armed Forces is the summation of the armed forces of the kingdom of Morocco. It was founded in 1956 (except the Royal Navy founded in 1960) after Morocco's independence from France and Spain. Before the French and Spanish occupation of Morocco, which started in 1912, the country's defence force was made of a regular Makhzen army, and of a less organized but much more powerful Berber tribes' militias. These Berber militias were able to resist the French and Spanish armies for over 30 years, from 1907 to 1933.
The U.S. Embassy in Rabat commented in 2008 that: 'Civilian control, if ascribed to the person of the King, is complete, but there is no real Defense Ministry. Outside the FAR, there is only a small administration. The military remains plagued by corruption, an inefficient bureaucracy, low levels of education in the ranks, periodic threats of radicalization of some of its soldiers, political marginalization, and the deployment of most of its forces in the Western Sahara.'
The modern Moroccan military is structured into six different branches. 
This data is from the Finance Law 2009. However, the U.S. Embassy Rabat cable linked above gives different figures for some of the armed services. Most significantly, they list the Navy with 7,800 personnel, but also say that the Gendarmerie consists of about 22,000 personnel.
During the period of the French protectorate of Morocco (1912–1956) large numbers of Moroccans were recruited for service in the Spahi and Tirailleur regiments of the French Army of Africa. During World War II more than 300,000 Moroccan troops (including goumier auxiliaries) served with the Free French forces in North Africa, Italy, France and Austria. The two world conflicts saw Moroccan units earning the nickname of "Todesschwalben" (death swallows) by German soldiers as they showed particular toughness on the battlefield . By the end of the World War II, Moroccan troops took part of the French Expeditionary Force engaged in the First Indochina War from 1946 to 1954.
The Spanish Army also made extensive use of Moroccan troops recruited in the Spanish Protectorate, during both the Rif War of 1921-26 and the Spanish Civil War of 1936-39. Moroccan Regulares, together with the Spanish Legion, made up Spain's elite Spanish Army of Africa. A para-military gendarmerie, known as the "Mehal-la Jalifianas" and modelled on the French goumieres, was employed within the Spanish Zone.
The Royal Armed Forces were created on 14 May 1956, after the French Protectorate was dissolved. Fourteen thousand Moroccan personnel from the French Army and ten thousand from the Spanish Armed Forces transferred into the newly formed armed forces. This number was augmented by approximately 5,000 former guerrillas from the "Army of Liberation" (see below). About 2,000 French officers and NCOs remained in Morocco on short term contracts, until crash training programs at the military academies of St-Cyr, Toledo and Dar al Bayda produced sufficient numbers of Moroccan commissioned officers.
Four years later, the Royal Moroccan Navy was established in 1960.
Full article ▸