Morocco is the centre of the Almoravid Sultanate from 1063 until 1147. In 1147 the Sultanate of Morocco becomes a fact under the Almohad Sultanate. This rule is succeeded by the rule of the Mernid dynasty in 1268 and by the Saadian dynasty in 1555. In 1666 the Sharifi Moroccan State under the A`lawi Filali Sharifi dynasty starts. Morocco's location and resources lead to early competition among European powers in Africa, beginning with successful Portuguese efforts to control the Atlantic coast in the 15th century. France shows a strong interest in Morocco as early as 1830. In 1860 Morocco cedes Western Sahara and Ifni to Spain.
Following recognition by the United Kingdom in 1904 of France's "sphere of influence" in Morocco, the Algeciras Conference (1906) formalizes France's "special position" and entrusts policing of Morocco to France and Spain jointly. In the Treaty of Fez (1912) the Sultan of Morocco has to accept a French protectorate in the main part of the country (French Morocco)and a Spanish protectorate in the north and the extreme south of the country. Tanger becomes a city under international administration in 1923. In resistance to the Spanish protectorate and independent Rif exists from 1921 until 1926. In 1927 Muhammad V becomes sultan of Morocco.
After World War II Morocco is promised independence but the protectorates last until 1956. France's exile of Muhammed V in 1953 and his replacement by the unpopular Mohammed Ben Aarafa, whose reign is perceived as illegitimate, sparks active opposition to the French protectorate. France allows Muhammed V to return in 1955, and the negotiations that lead to Moroccan independence begin the following year. In 1956 French Morocco becomes independent as Morocco, shortly after that the protectorate in Spanish Morocco ends and Tanger is transfered to Morocco.
The country is renamed Kingdom of Morocco in 1957. Dominant party is the Parti d'Independence "Istiqlal" (Independence Party). Between 1958 and 1960 the prime ministers are from this party, Muhammad Ahmed Balafrej and Abdallah Ibrahim. 1960 and 1963 there is no prime minister. Until 1963 Morocco is an absolute monarchy, but that year king Hassan II, ruler since 1961, introduces parliamentary government, although he holds power. Ahmed Bahnini of the Front de Défense des Institutions Constitutionnelles (Front for the Defence of Constitutional Institutions) becomes prime minister until 1965. He is not succeeded in 1965, but in 1967 the king reestablishes the premiership. From that time in the prime ministers are non-partisans. The new prime minister is Muhammad Benhima bin Taiyib. In 1969 Morocco acquieres the former Spanish enclave of Ifni. Spain, however, retains control over the small coastal enclaves of Ceuta and Melilla in the north. Benhami is succeded in 1969 by Ahmed Laraki, followed by Muhammad Karim Lamrani in 1971.
A new constitution of 1972 makes Morocco a constitutional monarchy. Elections are to be held in 1977. Ahmed Osman, related to the Rassemblement National d'Independents (National Rally of Independents, RNI) becomes prime minister. In 1976 Morocco annexes the northern part of the former Spanish territory of Western Sahara, followed in 1979 by the annexation of the Mauritian part of the Sahara. Parliamentary government is finally resumed and reasonably fair elections are held in 1977. But Hassan remained the real power in the country. Osman is succeeded in 1979 by Maati Bouabid, related to the Union Constitutionelle (Constitutional Union, UC). He in his turn is succeeded in 1983 by Muhammad Karim Lamrani, in 1986 by Azzedine Laraki and in 1992 by Muhammad Karim Lamrani again. In 1994 Abdellatif Filali takes office.
The elections of 1998 are won by left-wing parties and Abderrahmane Youssoufi of the Union Socialiste des Forces Populaires (Socialist Union of Popular Forces, USFP) becomes prime minister. In 1999 Hassan is succeeded after his death by Muhammad VI. After the 2002 parliamentary elections, which are considered largely free, fair and transparent, the king appoints Driss Jettou to lead a multi-party government.