Morocco (məˈrɒkoʊ), officially the Kingdom of Morocco, is a country in the Maghreb region of North Africa. It overlooks the Mediterranean Sea to the north and the Atlantic Ocean to the west, and has land borders with Algeria to the east, and the disputed territory of Western Sahara to the south. Morocco also claims the Spanish exclaves of Ceuta, Melilla and Peñón de Vélez de la Gomera, and several small Spanish-controlled islands off its coast. It spans an area of or , with a population of roughly 37 million. Its official and predominant religion is Islam, and the official languages are Arabic and Berber; French and the Moroccan dialect of Arabic are also widely spoken. Moroccan identity and culture is a mix of Arab, Berber, African and European cultures. Its capital is Rabat, while its largest city is Casablanca.
The region constituting Morocco has been inhabited since the Paleolithic era over 300,000 years ago, and the first Moroccan state was established by Idris I in 788. It was subsequently ruled by a series of independent dynasties, reaching its zenith as a regional power in the 11th and 12th centuries, under the Almoravid and Almohad dynasties, when it controlled most of the Iberian Peninsula and the Maghreb. Centuries of Arab migration to the Maghreb since the 7th century shifted the demographic scope of Morocco. In the 15th and 16th centuries, Morocco faced external threats to its sovereignty, with Portugal seizing some territory and the Ottoman Empire encroaching from the east. The Marinid and Saadi dynasties otherwise resisted foreign domination, and Morocco was the only North African nation to escape Ottoman dominion. The 'Alawi dynasty, which rules the country to this day, seized power in 1631, and over the next two centuries expanded diplomatic and commercial relations with the Western world. Morocco's strategic location near the mouth of the Mediterranean drew renewed European interest; in 1912, France and Spain divided the country into respective protectorates, reserving an international zone in Tangier.