page_title: Morocco
section_title: Foundation and early Islamic era
hierarchical_section_title: Morocco / History / Foundation and early Islamic era
caption_attribution_description: English: Idrisids_coin_minted_at_Al_Aliyah_Morocco_840 CE
context_page_description: 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, with land borders with Algeria to the east and Western Sahara to the south. Morocco also claims the exclaves of Ceuta, Melilla and Peñón de Vélez de la Gomera, all of them under Spanish jurisdiction, as well as 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 36 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 under Almoravid and Almohad rule, when it spanned parts of Iberia and northwestern Africa. The Portuguese Empire began in Morocco in the 15th century, following Portuguese conquests along the Moroccan coast, founding settlements which lasted into the 17th and 18th centuries. The Marinid and Saadi dynasties resisted foreign domination into the 17th century, allowing Morocco to remain the only northwest African country to avoid Ottoman occupation.
context_section_description: The Muslim conquest of the Maghreb, that started in the middle of the 7th century, was achieved by the Umayyad Caliphate early into the following century. It brought both the Arabic language and Islam to the area. Although part of the larger Islamic Empire, Morocco was initially organized as a subsidiary province of Ifriqiya, with the local governors appointed by the Muslim governor in Kairouan.
  The indigenous Berber tribes adopted Islam, but retained their customary laws. They also paid taxes and tribute to the new Muslim administration. The first independent Muslim state in the area of modern Morocco was the Kingdom of Nekor, an emirate in the Rif Mountains. It was founded by Salih I ibn Mansur in 710, as a client state to the Umayyad Caliphate. After the outbreak of the Berber Revolt in 739, the Berbers formed other independent states such as the Miknasa of Sijilmasa and the Barghawata.
  According to medieval legend, Idris ibn Abdallah had fled to Morocco after the Abbasids' massacre of his tribe in Iraq. He convinced the Awraba Berber tribes to break their allegiance to the distant Abbasid caliphs in Baghdad and he founded the Idrisid dynasty in 788. The Idrisids established Fes as their capital and Morocco became a centre of Muslim learning and a major regional power. The Idrissids were ousted in 927 by the Fatimid Caliphate and their Miknasa allies. After Miknasa broke off relations with the Fatimids in 932, they were removed from power by the Maghrawa of Sijilmasa in 980.
caption: Idrisid coin in Fes, 840 CE.
exif: {"Image ImageDescription": "", "Image Make": "SONY", "Image Model": "DSC-T10", "Image Orientation": "Horizontal (normal)", "Image Software": "Microsoft Windows Photo Gallery 6.0.6001.18000", "Image DateTime": "2009:03:01 05:49:12", "Image YCbCrPositioning": "Co-sited", "Image ExifOffset": "2320", "Image PrintIM": "[80, 114, 105, 110, 116, 73, 77, 0, 48, 51, 48, 48, 0, 0, 2, 0, 2, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]", "Image Padding": "[]", "Image OffsetSchema": "44", "EXIF ExposureTime": "1/30", "EXIF FNumber": "4", "EXIF ExposureProgram": "Program Normal", "EXIF ISOSpeedRatings": "800", "EXIF ExifVersion": "0221", "EXIF DateTimeOriginal": "2008:12:16 19:24:27", "EXIF DateTimeDigitized": "2008:12:16 19:24:27", "EXIF ComponentsConfiguration": "YCbCr", "EXIF CompressedBitsPerPixel": "8", "EXIF ExposureBiasValue": "0", "EXIF MaxApertureValue": "29/8", "EXIF MeteringMode": "CenterWeightedAverage", "EXIF LightSource": "Unknown", "EXIF Flash": "Flash did not fire, compulsory flash mode", "EXIF FocalLength": "389/25", "EXIF FlashPixVersion": "0100", "EXIF ColorSpace": "sRGB", "EXIF ExifImageWidth": "2304", "EXIF ExifImageLength": "3072", "EXIF FileSource": "Digital Camera", "EXIF SceneType": "Directly Photographed", "EXIF CustomRendered": "Normal", "EXIF ExposureMode": "Auto Exposure", "EXIF WhiteBalance": "Auto", "EXIF SceneCaptureType": "Standard", "EXIF Contrast": "Normal", "EXIF Saturation": "Normal", "EXIF Sharpness": "Hard", "EXIF Padding": "[]", "EXIF OffsetSchema": "4140"}