Islam came to Yemen around 630 during Muhammad's lifetime and the rule of the Persian governor Badhan. Thereafter, Yemen was ruled as part of Arab-Islamic caliphates, and became a province in the Islamic empire.
Regimes affiliated to the Egyptian Fatimid caliphs occupied much of northern and southern Yemen throughout the 11th century, including the Sulayhids and Zurayids, but the country was rarely unified for any long period of time. Local control in the Middle Ages was exerted by a succession of families which included the Ziyadids (818–1018), the Najahids (1022–1158), the Egyptian Ayyubids (1174–1229) and the Turkoman Rasulids (1229–1454). The most long-lived, and for the future most important polity, was founded in 897 by Yayha bin Husayn bin Qasim ar-Rassi. They were the Zaydis of Sa'dah in the highlands of North Yemen, headed by imams of various Sayyid lineages. As ruling Imams of Yemen, they established a Shia theocratic political structure that survived with some intervals until 1962.
After the introduction of coffee in the 16th century the town of al-Mukha (Mocha), on the Red Sea coast, became the most important coffee port in the world. For a period after 1517, and again in the 19th century, Yemen was a nominal part of the Ottoman Empire, although on both occasions the Zaydi Imams contested the power of the Turks and eventually expelled them.
Final years of pre-Islamic Yemen and arrival of Islam In the final pre-Islamic period, the Yemeni lands included the large tribal confederations Himyar, Hamdan, Madh'hij, Kindah, Hashid, Bakil, and Azd.
During the 6th century, Yemen was involved in the power struggles between the Christian Byzantine Empire and the Zoroastrian Sasanian Empire. Following persecutions of Christians by the Jewish Himyarites, in 525 the Christian Aksumite Empire, a Byzantine ally in what is now Ethiopia and Eritrea, conquered Yemen under the general Abraha. In turn, local tribal leaders turned to the Sasanians for aid. The latter took over the region in 575 under the general Wahrez and converted it into a province of the Sasanian Empire. The descendants of these Persian soldiers, known in Arabic as , dominated the capital, Sana'a, but the rest of the country in practice remained divided among a multitude of autonomous local rulers and tribal chiefs. After the dissolution of Persian rule in South Arabia, the turned to the emerging Islamic state under Muhammad in order to find support against local Arab rebels.
The last Persian governor, Badhan, converted to Islam on 6 AH (628 CE), thus nominally submitting the entirety of Yemen to the new faith. The actual extent of conversion in the country is not known, and the scarcity and lack of detail in the primary sources is exacerbated by the retroactive attempts, in later accounts, by each tribal group to provide an early conversion date for itself for reasons of prestige. In practice, the land remained much like it had been in pre-Islamic times, and the new religion became another factor in the internal conflicts that had traditionally afflicted Yemeni society. Towards the end of Muhammad's life, in 632, a certain al-Aswad al-Ansi proclaimed himself prophet and found widespread support among the Yemenis, although the exact motivation of his uprising is unclear. He captured Sana'a, but was killed by the and defecting members of his own faction in the same year.
Yemen as a province of the early caliphates
Rashidun era (632–661) After Muhammad's death, the so-called Wars of Apostasy broke out across the Arabian Peninsula. Muhammad's successor, the first Rashidun caliph, Abu Bakr (), sent troops from Medina into Yemen, and levied local forces to augment them. This allowed Muslim rule to survive the conflict. Many of the apostate leaders were pardoned and went on to play important roles in the early Muslim conquests.
Under the Rashidun caliphs, the first governors were sent to administer Yemen for the nascent Islamic empire. The known lists of governors are often unclear and contradictory, but represent almost the only information about the early history of Islamic Yemen. Governors are mentioned for the entirety of Yemeni territory, but also individually for Sana'a, al-Janad (based at Taiz), and Hadramawt. The governors of Sana'a appear to have at times exercised some control over the others, but even so their authority was often limited to the cities they were based in, and most of the country remained outside effective control. The early governors were usually chosen from senior Companions of Muhammad. The last of them, Ya'la ibn Umayya, served for twenty years and was only dismissed by the fourth Rashidun caliph, Ali ().
The Rashidun caliphs themselves also paid some attention to the affairs of Yemen, especially the spread of Islam. Judges and Qur'an instructors were appointed, and the Christian tribes of Najran evicted under Caliph Umar (), despite prior treaties with Muhammad and Abu Bakr guaranteeing their status. The Jewish population was allowed to remain, in exchange for the payment of the (poll tax).
The main events of the First Muslim Civil War (656–661) took place far from Yemen, but the country was nevertheless deeply affected. Yemenis were divided between the rival camps of Ali and Mu'awiya I (), and both sides sent their own troops into the country. Ali's partisans initially prevailed, but one of Mu'awiya's generals captured Najran and Sana'a for his master in 660.
Umayyad era (661–750)
The Umayyad Caliphate, founded by Mu'awiya, shifted their base from the Arabian Peninsula to Syria, but continued to pay great attention to Yemen. Governors were appointed directly by the caliph. During some periods, Yemen was administratively grouped together with Hijaz and Yamama. Still, the caliphal governors' actual control barely extended to the wider country, where the pre-Islamic elites still retained their position.
During most of the Second Muslim Civil War (683–692), Yemen was nominally under the control of the Mecca-based anti-caliph, Abdallah ibn al-Zubayr. However, his control over the country was tenuous, judging from the frequent alternation of governors during his rule. Ibn al-Zubayr's tenuous authority was not enough to protect Sana'a against the threat of the Kharijites of Oman and Bahrayn: in 686, the city had to bribe the Kharijites not to attack, and in the next year, its inhabitants were forced to swear allegiance to the Kharijite leader, Najda ibn Amir. Following the victory of the Marwanid branch of the Umayyads in the civil war, Sana'a surrendered to an Umayyad army without resistance.
The Marwanid caliphs made considerable investments in the country's infrastructure, leading to an upsurge in prosperity. As elsewhere in the Muslim world, Caliph Umar ibn Abd al-Aziz () gained a reputation for justice that carried over even into the local Shi'a traditions.
In spite of the tenuous caliphal authority, the Yemenis seldom rebelled against the Umayyads. A certain Abbad al-Ru'yani revolted in 725/6, but his motivation is unclear: according to some sources, he was a Himyarite self-proclaimed messiah, while others consider him a Kharijite. The most serious revolt occurred at the end of the period, in 746–748, as Umayyad power was weakened during the Third Muslim Civil War. It was headed by a Kindi tribesman, Abdallah ibn Yahya, who assumed the honorific title of Talib al-Haqq (), and proclaimed himself caliph in the Hadramawt. With support from the Ibadi Kharijites of neighbouring Oman, he advanced onto Sana'a. His army occupied Mecca and Medina, and even Basra for a while swore allegiance to him, before his uprising, as well as other tribal revolts of the Himyarites, were suppressed by the Umayyad general Abd al-Malik ibn Atiyya. However, the Ibadis of Hadramawt on that occasion obtained from Ibn al-Atiyya the right to choose their own governors, a privilege they kept for about a generation.
Abbasid era (750–847) The Third Muslim Civil War fatally weakened the Umayyad regime, culminating in the Abbasid Revolution, and the overthrow of the Umayyad Caliphate by the Abbasid Caliphate in 749–750.
The Abbasids continued the policy of the Umayyads with respect to Yemen. Frequently, members of the highest Abbasid aristocracy, including princes of the dynasty, served as governors. At other times, the province was attached to the Hijaz, whose governor sent a deputy to rule Yemen in his stead. In 759, the Abbasid governor, a native Yemeni named Abdallah ibn Abd al-Madan, tried to secede from the Caliphate. His revolt was suppressed by the Abbasid general Ma'n ibn Za'ida al-Shaybani, who went on to serve as governor of Yemen until 768. During his tenure, he brutally suppressed uprisings—mainly Ibadi-inspired—across the country, restoring a measure of peace and order.
Under Caliph Harun al-Rashid (, Muhammad ibn Khalid ibn Barmak, one of the famous Barmakids, was governor of Yemen. His time is recorded as one of prosperity for the capital Sana'a, but also of widespread poverty. In 800, the Himyarite chieftain al-Haysam ibn Abd al-Samad rose in revolt, but was defeated by Harun's governor Hammad al-Barbari. Hammad was successful in restoring peace to the region and securing the trade routes, but his harshness towards the local population led to his recall in 810.
During the civil war in 811–813 between Harun's sons, al-Amin and al-Ma'mun, Yemen initially belonged to al-Amin's camp, but one of al-Ma'mun's agents, Yazid ibn Jarir, managed to win the country over for his master. In 815, the Alid Ibrahim ibn Musa al-Kazim, son of the Twelver imam Musa al-Kazim, occupied Sana'a and the northern highlands and struck coins in his own name. He may even have briefly captured Mecca, but was defeated by Abbasid forces near Sana'a in the same year. Nevertheless, after the caliph had reached an understanding with the Alids and appointed Ibrahim's brother, Ali al-Ridha, as his heir-apparent, the same Ibrahim was appointed governor of Mecca and Yemen in 820. This resulted in a revolt by the incumbent governor, Hamdawayh, who had to be subdued by yet another expedition. Ibrahim remained as governor of Yemen until 828.
Direct Abbasid authority in Yemen survived until 847, when the autonomous Yu'firid dynasty defeated the Abbasid governor, Himyar ibn al-Harith, and captured Sana'a. Already during al-Ma'mun's time, however, local tribal or sectarian leaders began to rise and unite hitherto fragmented parts of the country under their authority, a process that would continue during the entire 9th century.
Yemeni textiles, long recognized for their fine quality, maintained their reputation and were exported for use by the Abbasid elite, including the caliphs themselves. The products of Sana'a and Aden have been particularly important in the east–west textile trade.
Collapse of Abbasid authority and rise of native dynasties The first local dynasty to emerge in Yemen during the 9th century were the Ziyadids. The dynasty was established by Muhammad ibn Abdallah ibn Ziyad, a descendant of a cadet branch of the Umayyad dynasty, who was appointed by al-Ma'mun in 817 to suppress revolts in the western coastal plain of the Tihama. In 819, Ibn Ziyad founded Zabid as his capital. At the height of the dynasty, its power extended along the coasts to Aden in the south and Mirbat in the west, and Zabid was so prosperous as to be known as 'Baghdad of the Yemen'. Unlike the rest of the country, where Shi'a sympathies were strong, the Tihama was solidly pro-Sunni, and the Ziyadid dynasty remained aligned with the Sunni Abbasids against the Shi'a regimes that arose during the late 9th century.