Abū'l-ʿAbbās Aḥmad ibn Ḥasan (Arabic: أبو العباس أحمد بن حسن; 1222/32 – 19 January 1302), better known by his regnal name al-Ḥākim (I) bi-Amri'llāh (Arabic: الحاكم بأمر الله, lit. 'He who rules by the word of God') was the second Abbasid caliph of Cairo under the Mamluk Sultanate, and the progenitor of all the subsequent caliphs of Cairo. First proclaimed by the mamluk emir of Aleppo against his predecessor al-Mustansir II, he was formally recognized by sultan Baybars in 1262.
Ahmad ibn Hasan was allegedly a descendant of the Abbasid caliph al-Mustarshid (r. 1118-1135) through his son Abu Bakr (or through another son, caliph al-Rashid). Nothing is known of his life before the Mongol sack of Baghdad in 1258. The Mongol army executed the reigning caliph, al-Musta'sim, and as part of a policy of eliminating the Abbasid family members, intended to immure him. The builder commissioned for this purpose instead took pity on him and let him escape alongside other companions, to the Bedouin Khafaja tribe on the lower Euphrates in early 1259.
Ahmad's claim of being an Abbasid was accepted by his Bedouin hosts, who forwarded him to Syria, where he met Isa ibn Muhanna, chief of Al Fadl Bedouin. Isa informed the Ayyubid emir of Damascus, al-Nasir Yusuf, of Ahmad's arrival, who then summoned him to Damascus. However, the Mongol invasion of Syria postponed this journey. In March 1260, Damascus fell to Mongols and al-Nasir Yusuf fled to Cairo. The same year, the mamluks of Ayyubid sultan as-Salih Ayyub, under their sultan Qutuz, defeated the Mongols at Ain Jalut, and drove them out of Syria. At this point, Isa ibn Muhanna again attempted to alert the paramount sultan of Ahmad and his eligibility for the vacant caliphate.
Qutuz rewarded Isa by formally granting him Salamiyya as an iqta, and (according to later sources) instructed Isa to send Ahmad to Cairo at a later date for official investiture. He also dispatched his emir Kilij al-Baghdadi to pledge allegiance to Ahmad on his behalf and to accompany him on a campaign to recover Baghdad from the Mongols. Their combined forces captured several towns along the Euphrates but were defeated by a Mongol army near al-Fallujah in late 1260, forcing Ahmad to withdraw to Salamiyya.
Two months after Ain Jalut, a group of Mamluks assassinated Qutuz, possibly with the involvement of Baybars al-Bunduqdari, who succeeded him as sultan. Ahmad remained in Salamiyya for several months until June 1261, when the Mamluk governor of Damascus, Taybars al-Waziri, summoned him and sent him on to Cairo. On the way, Ahmad learned that Baybars had already installed another Abbasid survivor, Ahmad ibn al-Zahir, an uncle of al-Musta’sim, as caliph al-Mustansir billah. With a caliph already proclaimed, Ahmad feared that that he was likely heading to be imprisoned or killed, so he fled back to Salamiyya. By then Isa ibn Muhanna was in conflict with Aqqush al-Barli, the Mamluk emir of Aleppo and a rival of Baybars.
United by a common interest in wider acceptance for their respective ambitions, Aqqush helped al-Hakim acquiring broad recognition as caliph in Syria and Northern al-Jazira, while he lent legitimacy to Aqqush’s rule over these lands. The same month, Aqqush pledged allegiance to Ahmad as caliph under the regnal title al-Hakim bi-Amr Allah, minted coins in his name, and had his name recited in the Friday sermon.
Baybars, meanwhile, set out to bring Syria under his control. In August 1261, after a series of skirmishes with the sultan's troops, Aqqush offered his submission, but Baybars only agreed to accept it in person in Cairo. Around the same time, Aqqush learned that Baybars was sending out two forces: one to drive him out of Aleppo, and another under al-Mustansir to retake Baghdad from the Mongols. Possibly as a gesture of goodwill toward Baybars, Aqqush gave al-Hakim 1,000 soldiers to join al-Mustansir’s expedition. In October, this force reached the town of Ana, but its inhabitants refused to open the gates, declaring that they would accept only the “true caliph” al-Mustansir, whom the sultan himself had invested. Al-Mustansir’s army arrived soon afterward, and most of al-Hakim’s troops defected to him. Al-Mustansir urged al-Hakim to unite for the sake of the Abbasid family. Left with no alternative, al-Hakim gave up his claim and recognized al-Mustansir as the rightful caliph.
Strengthened by al-Hakim’s troops, al-Mustansir pressed on and seized the town of Hit before encountering a Mongol army near al-Anbar on the Euphrates. In the ensuing battle on 28 November 1261, the caliphal army was defeated and al-Mustansir was killed. Al-Hakim, who may have betrayed his ally by withdrawing at the decisive moment, escaped with almost fifty survivors to Isa ibn Muhanna at al-Rahba. From there, he continued west to Damascus and then to Cairo, arriving in February 1262.
By the time al-Hakim reached Cairo, the enthusiasm surrounding recently proclaimed al-Mustansir had faded away. Baybars was no longer as invested in receiving caliphal legitimacy, with al-Mustansir's name already removed from coinage. Baybars granted al-Hakim a stipend and lodged him in the Cairo citadel, where he spent most of 1262 without receiving a formal oath of allegiance from the sultan.
By October 1262, however, Baybars needed al-Hakim when Berke Khan, the recently converted Muslim Khan of the Golden Horde, approached him to form an alliance against the Ilkhanate. Berke had backed the losing side, Ariq Böke, in the recent Mongol civil war, and he had been further angered by Hulegu’s sack of Baghdad. On 12 November 1262, Baybars formally pledged allegiance to al-Hakim, who in turn confirmed the sultan’s authority over his lands. Baybars also presented the caliph before the Golden Horde envoys as a central figure of religion protected by the sultan of Cairo. The envoys attended al-Hakim's first Friday sermon and prayer, and Baybars sent Berke a copy of the sermon and a genealogy tracing al-Hakim to the Prophet Muhammad. When another Golden Horde embassy arrived in Cairo in May 1263, al-Hakim used his farewell address to call on Berke to join the jihad against the Ilkhanate and urged the envoys to speak well of Baybars to their master. In the envoys’ presence, Baybars also inducted al-Hakim into the futuwwa brotherhood.
Once the alliance with Berke was formalized, al-Hakim was gradually withdrawn from the public life, and his name too was removed from the coinage. Baybars barred military officers from visiting him and severely restricted his movements. Only scholars, who posed less of a threat, were allowed to see him. Al-Hakim spent most of the sultan's reign in this confinement, though the latter continued to draw on the caliph’s authority, publicizing his investitures by the caliph and his predecessor in inscriptions.
Reign under Barakah and Qalawun
Baybars died on 30 June 1277, and was succeeded by his son al-Sa'id Barakah. Lacking a strong power base of his own, Barakah relied on the caliph as a mediator with the rival mamluk emirs. When he began replacing his father’s emirs with his own mamluks in key positions, they revolted in 1279. As his support dwindled, the emirs besieged the Citadel until Barakah agreed to abdicate and go into exile at al-Karak. He was replaced by his younger brother, al-Adil Salamish, with the powerful emir Qalawun as regent. The caliph’s name, which had been restored to the coinage under Barakah, was removed again and replaced with Qalawun’s. By November 1279, Qalawun had amassed enough power to usurp Salamish and proclaim himself sultan al-Malik al-Mansur.
Under Qalawun, the restrictions on al-Hakim grew tighter still. The caliph was excluded from official ceremonies and played no role in politics. Unlike Baybars and his sons, Qalawun did not even seek formal investiture from the caliph on his accession, with al-Hakim probably not even present at the ceremony. Even so, Qalawun continued to draw on the symbolic and theoretical value of the caliphate to legitimize his rule. In 1280 the governor of Damascus Sunqur al-Ashqar attempted to establish a rival sultanate, declaring himself sultan and minting coins in the caliph’s name. Qalawun responded tersely that the caliph was under his “protection,” not Sunqur’s, which made Qalawun the legitimate sultan.