The Abbasid army under Muhammad ibn Sulayman al-Katib deals a crushing defeat to the Qarmatians at the Battle of Hama.

The Battle of Hama was fought some 24 km (15 mi) from the city of Hama in Syria on 29 November 903 between the forces of the Abbasid Caliphate and the Qarmatians. The Abbasids were victorious, resulting in the capture and execution of the Qarmatian leadership. This weakened the Qarmatian presence in northern Syria, which was finally eradicated after the suppression of another revolt in 906. More importantly, it paved the way for the Abbasid attack on the autonomous Tulunid dynasty and the reincorporation of the Tulunid domains in southern Syria and Egypt into the Abbasid Caliphate.

The Abbasid Caliphate ( or Arabic: اَلْخِلَافَةُ ٱلْعَبَّاسِيَّةُ, al-Khilāfah al-ʿAbbāsīyah) was the third caliphate to succeed the Islamic prophet Muhammad. It was founded by a dynasty descended from Muhammad's uncle, Abbas ibn Abdul-Muttalib (566–653 CE), from whom the dynasty takes its name. They ruled as caliphs for most of the caliphate from their capital in Baghdad in modern-day Iraq, after having overthrown the Umayyad Caliphate in the Abbasid Revolution of 750 CE (132 AH). The Abbasid Caliphate first centered its government in Kufa, modern-day Iraq, but in 762 the caliph Al-Mansur founded the city of Baghdad, near the ancient Babylonian capital city of Babylon. Baghdad became a center of science, culture, philosophy and invention in what became known as the Golden Age of Islam.

The Abbasid period was marked by dependence on Persian bureaucrats (notably the Barmakid family) for governing the territories as well as an increasing inclusion of non-Arab Muslims in the ummah (national community). Persian customs were broadly adopted by the ruling elite, and they began patronage of artists and scholars. Despite this initial cooperation, the Abbasids of the late 8th century had alienated both non-Arab mawali (clients) and Persian bureaucrats. They were forced to cede authority over al-Andalus (current Spain and Portugal) to the Umayyads in 756, Morocco to the Idrisids in 788, Ifriqiya and Sicily to the Aghlabids in 800, Khorasan and Transoxiana to the Samanids and Persia to the Saffarids in the 870s, and Egypt to the Isma'ili-Shia caliphate of the Fatimids in 969.

The political power of the caliphs was limited with the rise of the Iranian Buyids and the Seljuq Turks, who captured Baghdad in 945 and 1055, respectively. Although Abbasid leadership over the vast Islamic empire was gradually reduced to a ceremonial religious function in much of the Caliphate, the dynasty retained control of its Mesopotamian domain during the rule of Caliph Al-Muqtafi and extended into Iran during the reign of Caliph Al-Nasir. The Abbasids age of cultural revival and fruition ended in 1258 with the sack of Baghdad by the Mongols under Hulagu Khan and the execution of Al-Musta'sim. The Abbasid line of rulers, and Muslim culture in general, re-centred themselves in the Mamluk capital of Cairo in 1261. Though lacking in political power (with the brief exception of Caliph Al-Musta'in of Cairo), the dynasty continued to claim religious authority for a few years after the Ottoman conquest of Egypt in 1517.