Morocco as part of the Arab Caliphate
By the beginning of the VIII century, Morocco was inhabited by Berber tribes from the Sanhaj group: Gomara – on the Mediterranean coast; bergvata – on the Atlantic coast between the Straits of Gibraltar and the mouth of Umm-ere-Rbii; miknasa – in the center; Masmuda – on the western slopes of the Big Atlas and on the Susa bank of Umm al -Rbii ; haskura – between Sus and Dra; Lemta and Lemtuna – on the left bank of the Dra. These tribes mainly retained traditional beliefs, but Christianity and Judaism were also common.
In the 700s, Arab troops, led by the governor of Ifriqi Moussa Ibn Nusayr, invaded Morocco. The Arabs conquered the Berber tribes to the Atlantic and reached Sigilmasa in Tafilalete. Around 702, Musa ibn Nusayr took possession of Tangier. Berbers forcibly converted to Islam, among them began to spread Arabic. The Arabs introduced irrigated crops in Morocco — rice, sugarcane, cotton, and more drought-resistant wheat.
Together with the Berber tribes, the Arabs, under the leadership of Musa ibn Nusayr and Tariq ibn Ziyad, defeated the Vestgoth kingdom in 711-718 and captured most of the Iberian Peninsula.
Idrisid state
In the 1st half of the 8th century, the Maghrib became a place of refuge for many opponents of official Islam — the Kharijites, various currents of Shiites and others. These movements have gained a great influence among the Berber tribes. In 739–742, a major uprising of the Kharijites took place, which led to the fall of the power of the Caliphate in part of Morocco and the formation of the Midrarids state in Tafilalte with its center in Sigilmas. On the Atlantic coast an association of Berber tribes of Bergvat appeared in the Tamesna region. The first major Islamic state in Morocco was the Idrisid power, formed in 789 by Idris I, a descendant of the Prophet Muhammad. The capital of Idrisid, the city of Fez, became an important center of culture and trade of the Maghreb. In 859, the Islamic University Karawyn was founded in Fez, many prominent geographers, historians, philosophers, and poets worked here. By the middle of the 9th century, the state of Idrisids weakened and divided into a number of principalities. At the beginning of the X century, the territory of Morocco was conquered by the Fatimid Ismaili caliphate. In the 2nd half of the 10th century Fatimids and the Cordoba Caliphate fought for power over Morocco. At the end of the 10th and mid-11th centuries, Meknas and Magrasum (vassals of Cordoba) dominated among the tribes of the central part of Morocco, the eastern part of the country was under the influence of the Zirid dynasty.
State of Almoravids
The Arab state reached its greatest prosperity during the Almoravid and Almohad dynasties in the 11th – 12th centuries. Under the Almoravids, Morocco was the center of a vast empire that occupied the territories of modern Algeria, Libya, Tunisia and the vast territories of Spain and Portugal. The beginning of the Almoravid Empire was laid by the military monastic order, formed from the Berber tribes of the Lemtuna group of the Sanhaj in the territory of modern Mauritania. The Almoravids were supposed to lead an ascetic way of life in strict accordance with the provisions of the Malikit Sunniks and learn the art of war to fight the enemies of the faith. Their leader was Abdullah Ibn Yasin, who built the Ribat and began the conquest of the Berber tribes of the Sahara. After the capture of Audagosta in 1054, the lands from Senegal and Upper Niger to Tafilalth came under the rule of the Almoravids. The military command was in the hands of representatives of the ruling family of the Lemtuna tribe: Emir Yahya ibn Omar, and then his brother Abu Bakr ibn Omar, who became the leader of the Almoravids after the death of Abdullah ibn Yasin (1059). Almoravides subjugated Southern Morocco, defeated non-Sunni states in Tafilalte (Kharijites), in Sousse (Shiites, 1056), bergvata in Shaviyi (1059); they took Theath (1069) and secured (by 1082) the religious unity of Morocco and Western Algeria based on Sunni Islam. The capital of the state of Ghana (1076) was seized in the south. The conquests were accompanied by the destruction of “infidels” and “apostates”, as well as the fight against “unrighteous rulers” and “illegal taxes”, which provided the Almoravids with the support of the people and contributed to the rapid success and growth of the movement. In 1061, Abu Bakr ibn Omar went to the Sahara to suppress the uprising, entrusting the command of the army in the north to his nephew Yusuf ibn Tashfin ; who then took the title of Emir al-muslimin (sovereign of the Muslims) and after the death of Abu Bekr (1087) became the religious and secular head of the Almoravids. At the request of the rulers of the small Muslim states of the Iberian Peninsula, who were threatened by the Reconquista, Yusuf ibn Tashfin landed in Spain in 1086, repelled the onslaught of Christians, defeating Salak, and by 1090 subjugated Muslim Spain. After the death of Yusuf ibn Tashfin ( 1106 ), his son Ali inherited a huge state, including Western Sahara, Morocco, Western Algeria, Muslim Spain and the Balearic Islands. The capital of the state was the city of Marrakesh, founded around 1070 by Abu Bakr ibn Umar. The extortions and excesses of the troops and rulers, especially under the successors of Yusuf ibn Tashfin, caused widespread discontent, which was intensified by the religious intolerance of the Almoravides. The Almoravid state weakened the lack of unity in the leadership of the country. The Almoravids were defeated in the fight against the Almohads, who in 1146 took Marrakesh.
State of Almohad
In 1146-1161, the Almohades defeated the Almoravid state, conquered the territory of Morocco and Southern Spain. On the coastal plains of Morocco, the Almohades settled the Arab tribes of Banu Hilal, Banu Suleim and Banu Makil invading the Maghreb, which greatly accelerated the process of Arabization of the country. The rise of the Almohad state continued until 1212, when its troops were defeated by the Spanish Christian kingdoms at Las Navas de Tolosa. After that, the weakening of the state began, which ended in 1269 with the coming to power of the Marinid dynasty.
The Marinid and Wattasid dynasties
At the end of XII – middle XV centuries the country was ruled by the Marinid dynasty. In 1472-1554 the most powerful in the territory of Morocco was the Wattasid dynasty, which was replaced by the Saadi, who ruled the country to the middle XVII century.
Saadit Dynasty
The revival of Morocco occurred in the XVI – XVII centuries, especially under Sultan Ahmad al-Mansur, whose rule is called the “golden age” of the country. At this time (1591), Moroccan troops under the leadership of Judar Pasha captured Songhai, a state in Western Sudan, putting under its control the trans-Saharan trade in salt and gold.
Since the beginning of the XV century, several port cities were under the control of the Portuguese and Spaniards, but by the XVI century, most cities were again dominated by the Moroccan Sultan. The state flourished and reached its greatest volume, capturing the western part of Algeria and stretching south to Guinea. The Portuguese were expelled from the possessions they occupied in Morocco, and King Sebastian was defeated in 1578 in the battle of Alcácer Quibir.
State of Alauit
After the death of Ahmad, the most powerful of the sharifs (in 1603), the state began to decline due to constant internal wars, so Moulay Rashid ibn Sheriff, a descendant of Ali and Fatima, was easy to overthrow the first sheriffs dynasty and establish the new, still ruling dynasty of the Alids. The most famous of them is Moulay Ismail, who reigned from 1672 to 1727, as the greatest despot. Under his successors, civil strife over the throne dominated, leading the country more and more to decline, until assuming of the throne in 1757 by Moulay-Slimane, distinguished by gentleness and a desire to introduce European culture.
In the 17th and 19th centuries, Morocco was considered a pirate state, since in many cities actual power was in the hands of sea pirates. For example, the Republic of Sale, which occupied a small part of the Moroccan coast, in 1627–1668, in fact, was politically independent from the rest of the country. It is interesting that this did not prevent Morocco from carrying out diplomatic functions, in 1777 Morocco was the first state to recognize the independence of the United States.