Mecca was never the capital of any of the Islamic states but Muslim rulers did contribute to its upkeep. During the reigns of Umar (634–44 CE) and Uthman ibn Affan (644–56) concerns of flooding caused the caliphs to bring in Christian engineers to build barrages in the low-lying quarters and construct dykes and embankments to protect the area round the Kaaba.[35]
Muhammad's migration to Medina shifted the focus away from Mecca. This focus moved still more when Ali, the fourth caliph, took power choosing Kufa as his capital. The Umayyad Caliphate moved the capital to Damascus in Syria and the Abbasid Caliphate to Baghdad, in modern-day Iraq, which remained the center of the Islamic Empire for nearly 500 years. Mecca re-entered Islamic political history during the Second Islamic Civil War, when it was held by Abd Allah ibn al-Zubayr, an early Muslim who opposed the Umayyad caliphs. The city was twice besieged by the Umayyads, in 683 and 692. For some time thereafter the city figured little in politics, remaining a city of devotion and scholarship governed by the Hashemite Sharifs.
In 930, Mecca was attacked and sacked by Qarmatians, a millenarian Ismaili Muslim sect led by Abū-Tāhir Al-Jannābī and centered in eastern Arabia.[50] The Black Death pandemic hit Mecca in 1349.[51]
In 1517, the Sharif, Barakat bin Muhammed, acknowledged the supremacy of the Ottoman Caliph but retained a great degree of local autonomy.[52]
In 1803 the city was captured by the First Saudi State,[53] which held Mecca until 1813. This was a massive blow to the prestige of the (Turkish) Ottoman Empire, which had exercised sovereignty over the holy city since 1517. The Ottomans assigned the task of bringing Mecca back under Ottoman control to their powerful Khedive (viceroy) of Egypt, Muhammad Ali Pasha. Muhammad Ali Pasha successfully returned Mecca to Ottoman control in 1813.
In 1818, followers of the Salafi juristic school were again defeated, but some of the Al Saud clan survived and founded the Second Saudi State that lasted until 1891 and led on to the present country of Saudi Arabia.
Mecca was regularly hit by cholera outbreaks. Between 1830 and 1930 cholera broke out among pilgrims at Mecca 27 times.
