Morocco, formally the Kingdom of Morocco, is the northwesternmost nation in North Africa's Maghreb area. It has land boundaries with Algeria to the east and the disputed area of Western Sahara to the south, and it overlooks the Mediterranean Sea to the north and the Atlantic Ocean to the west. Moroccan territory also includes the Spanish exclaves of Ceuta, Melilla, and Peón de Vélez de la Gomera, as well as other minor Spanish-controlled islands off its coast. It has a population of over 37 million people and an area of 446,300 km2 (172,300 sq mi) or 710,850 km2 (274,460 sq mi). Its official religion is Islam, and its official languages are Arabic and Berber; the Moroccan variety of Arabic and French are also commonly spoken. Moroccan identity and culture are a fusion of Berber, Arab, and European influences. Rabat is the capital, while Casablanca is the biggest city.
Inhabited since the Paleolithic Era about 90,000 years ago, Idris I created the first Moroccan kingdom in 788. It was afterwards governed by a succession of autonomous dynasties, reaching its height as a regional power in the 11th and 12th centuries, when it dominated much of the Iberian Peninsula and the Maghreb under the Almoravid and Almohad dynasties. Morocco experienced external challenges to its sovereignty in the 15th and 16th centuries, with Portugal taking some land and the Ottoman Empire approaching from the east. Otherwise, the Marinid and Saadi dynasties resisted foreign dominance, and Morocco was the only North African kingdom to avoid Ottoman rule. The Alaouite family, which still administers the nation today, acquired power in 1631 and established diplomatic and economic contacts with the Western world during the following two centuries. Morocco's strategic position at the mouth of the Mediterranean piqued European interest again; in 1912, France and Spain partitioned the country into protectorates, with Tangier designated as an international zone. Following a series of riots and revolts against colonial authority, Morocco achieved independence and reunified in 1956.
Morocco has been largely stable since its independence. It has the African continent's fifth-largest economy and major influence in both Africa and the Arab world; it is seen as a middle power in global affairs and is a member of the Arab League, the Union for the Mediterranean, and the African Union. Morocco is a semi-constitutional unitary monarchy with an elected parliament. The King of Morocco and the prime minister lead the executive branch, while the two houses of parliament, the House of Representatives and the House of Councillors, have legislative authority. The Constitutional Court has judicial authority and may assess the legality of legislation, elections, and referendums. The king has broad administrative and legislative powers, particularly over the military, foreign policy, and religious matters; he may make lawful decrees known as dahirs, and he can dissolve parliament after consulting the prime minister and the president of the constitutional court.
Morocco claims control of Western Sahara, a non-self-governing area that it has designated as its Southern Provinces. After Spain decided to decolonize the area and hand over sovereignty to Morocco and Mauritania in 1975, a guerrilla conflict erupted between those governments and part of the locals. Mauritania renounced its claim to the territory in 1979, but the struggle raged on. A cease-fire deal was achieved in 1991, but the question of sovereignty remained unresolved. Morocco now controls two-thirds of the area, and attempts to end the conflict have so far failed to break the political impasse.