Morocco, officially the Kingdom of Morocco, is a country located 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 exclaves of Ceuta, Melilla and Peñón de Vélez de la Gomera and several small Spanish-controlled islands off its coast. The capital is Rabat and the largest city is Casablanca. Morocco spans an area of 710,850 km² and has a population of over 37 million.
Since the foundation of the first Moroccan state by Idris I in 788 AD, the country has been ruled by a series of independent dynasties, reaching its zenith in the 11th and 12th centuries under the Almoravid and Almohad dynasties, when it encompassed parts of Iberia as well as part of northwestern Africa. Beginning in the 15th century, the Portuguese Empire extended to include parts of Morocco: Portugal conquered territory along the Moroccan coast and founded settlements some of which endured into the 18th century.