# Al-Hafiz

Abūʾl-Maymūn ʿAbd al-Majīd ibn Muḥammad ibn al-Mustanṣir, better known by his regnal name as al-Ḥāfiẓ li-Dīn Allāh (Arabic: الحافظ لدين الله, lit. 'Keeper of God's Religion'), was the eleventh Fatimid caliph, ruling over Egypt from 1132 to his death in 1149, and the 21st imam of Hafizi Isma'ilism.
Al-Hafiz first rose to power as regent after the death of his cousin, al-Amir bi-Ahkam Allah, in October 1130. Al-Amir had only left an infant son, al-Tayyib, as a possible successor, so al-Hafiz—as the oldest surviving member of the dynasty—became regent. Al-Tayyib was apparently sidelined and possibly killed by the new regime, which was in turn overthrown within a few days by the army under Kutayfat. The latter imprisoned al-Hafiz, and moved to depose the Fatimids and replace Isma'ilism with a personal regime, possibly based on Twelver Shi'ism, with himself as the Hidden Imam's all-powerful vicegerent. Kutayfat's regime was toppled when he was murdered by Fatimid loyalists in December 1131, and al-Hafiz was freed and restored as regent.
On 23 January 1132, al-Hafiz proclaimed himself as the legitimate Isma'ili imam and caliph. While necessary in view of the lack of another heir, the succession was highly irregular, as the Isma'ili imamate had previously only been passed from father to son, by explicit designation (naṣṣ). Al-Hafiz was largely accepted in the Fatimid-ruled territories, but many Isma'ili followers abroad refused to recognize him and regarded the vanished al-Tayyib as their imam, causing the Hafizi–Tayyibi schism in Musta'li Isma'ilism. Even in Egypt, his legitimacy was repeatedly challenged, and his reign was troubled by constant uprisings and power struggles. In an effort to bolster his legitimacy, al-Hafiz was particularly active in the construction and restoration of shrines dedicated to members of the wider Alid family. Al-Hafiz's reign was mostly quiet on the external front. Despite continuing hostilities with the Kingdom of Jerusalem around Ascalon, both powers were preoccupied elsewhere for the most part. The Fatimid court also maintained contact with the Burids in Syria and King Roger II of Sicily, who at this time began his expansion into the former Fatimid domains of Ifriqiya, and adopted many of the practices of the Fatimid court for his own administration.
As ruler, al-Hafiz tried to rein in his over-mighty viziers, with mixed success. He was repeatedly forced to give way to the demands of various military factions, and was ultimately unable to halt the evolution of the vizierate into a de facto sultanate independent of the caliph. Thus al-Hafiz's own son Hasan forced him to name him vizier in 1134, ousting another of the Caliph's sons from the post. Hasan's reign proved tyrannical and he was overthrown by the army in March 1135. The appointment of the Christian Bahram al-Armani to the vizierate after that caused a severe reaction among the Muslim population due to Bahram's pro-Christian policies. This led to another uprising and the appointment of the Sunni Ridwan ibn Walakhshi to the vizierate in 1137. Ridwan not only instituted anti-Christian and anti-Jewish measures, but aimed to overthrow al-Hafiz and replace the Fatimid dynasty with a Sunni regime headed by himself. With the support of the Cairo populace, al-Hafiz thwarted his ambitions and ousted Ridwan in 1139. For the next ten years, the Caliph ruled without a vizier, instead entrusting the administration to a succession of secretaries, with Ibn Masal as leading minister. This period was plagued by uprisings and natural disasters, but al-Hafiz persevered until his death in October 1149. His successors would be reduced to puppets at the hands of powerful viziers, until the end of the Fatimid Caliphate in 1171.


## Origin
The future al-Hafiz was born as Abd al-Majid at Ascalon in AH 467 (1074/5 CE) or 468 (1075/6). His father was Abu'l-Qasim Muhammad, a son of the reigning Fatimid caliph, al-Mustansir (r. 1036–1094). In later life he was also called by the epithet (kunya) of Abu'l-Maymun. His early life, before he was thrust to the forefront of politics, is almost unknown. As an adult, he is reported to have had a strong mind and mild nature, fond of hoarding things, and to be strongly interested in alchemy and astronomy; he is known to have kept several astronomers in his employ.


## Regency and imprisonment
On 7 October 1130, Caliph al-Amir bi-Ahkam Allah (r. 1101–1130) was assassinated. He left only a six-month-old son, Abu'l-Qasim al-Tayyib, to succeed him, with no designated regent or serving vizier, as al-Amir had resumed the personal direction of government affairs, instead of entrusting the administration to a potentially dangerously powerful vizier. Al-Amir's murder put a premature end to his attempts to once again concentrate power in the hands of the caliph instead of over-mighty generals and ministers. Given the fragility of succession, it furthermore endangered the very survival of the Fatimid dynasty.
At this time, Abd al-Majid was the oldest surviving male of the dynasty. What happened next appears to have effectively been a coup: two of al-Amir's favourites, Hizar al-Mulk Hazarmard (or Jawarmard) and Barghash, who had influence over the army, allied themselves with Abd al-Majid, to control the government. Abd al-Majid was to become regent, while Hazarmard (winning out over Barghash) would become vizier, and the Armenian Abu'l-Fath Yanis the commander-in-chief and chamberlain to the regent. Hazarmard evidently hoped to establish himself as a quasi-sultan in the style of the all-powerful Armenian vizier Badr al-Jamali and his son al-Afdal Shahanshah while Abd al-Majid may have supported him with the aim of gaining the throne for himself.
As de facto head of state, Abd al-Majid used the title of walī ʿahd al-muslimīn. Previously this was the formal title of the Fatimids' designated successor, but in this context is to be understood as regent. It is unclear, however, in whose name this regency was exercised. Most sources report that even the existence of al-Amir's infant son was concealed, and al-Tayyib disappears completely from the record after that. How the existence of a child whose birth had been accompanied by public celebrations and proclamations, was so effectively concealed is unknown. Modern scholars speculate that al-Tayyib may have died in infancy, possibly even before his father; but at least one contemporary anonymous Syrian source maintains that he was murdered on Abd al-Majid's orders. Instead of al-Tayyib, the new regime maintained that al-Amir had left a pregnant concubine, and that the caliph, having dreamed of his impending death, had declared this unborn child to be a son and his designated (naṣṣ) successor, thus effectively bypassing al-Tayyib. What came of this pregnancy is likewise unclear, as different sources report that the concubine either bore a daughter or that the foetus could not be found, or that al-Hafiz killed the baby soon after.

Whatever the ambitions and intentions of the leaders of the new regime were, they were cut short within a fortnight of al-Amir's death. At the ceremony of the new vizier's investiture, the army, assembled at the Bayn al-Qasrayn square between the caliphal palaces, rose in revolt and demanded the appointment of Kutayfat, the only surviving son of al-Afdal Shahanshah, as vizier. The palace was invaded, Hazarmard was executed and his severed head carried through the streets of Cairo, and on 21 October, Kutayfat was invested as vizier with the titles of his father and grandfather. Formally, Abd al-Majid retained his position of regent, and coins and decrees were issued jointly in his name and that of Kutayfat. In reality, Abd al-Majid was held a prisoner in one of the palace treasuries, guarded by the military commander (and future vizier) Ridwan ibn Walakhshi. Soon, however—possibly after the expected birth of a male heir did not occur—Kutayfat proclaimed the dynasty deposed, and abandoned Isma'ilism as the state religion. He instead proclaimed himself as the vicegerent of a shadowy 'Expected One' (al-Muntaẓar) and 'Rightly-Guided' (al-Mahdī) imam, who was given no name other than the kunya Abu'l-Qasim. The medieval sources explain this as a turn to Twelver Shi'ism, where expectation of the Hidden Imam is a core tenet. The historian Heinz Halm points out that this is nowhere explicitly attested in Kutayfat's own proclamations. Rather, Kutayfat's claim was a convenient political device which not only sidestepped the Fatimid claims to the imamate, but allowed him to rule, in the words of the historian Samuel Miklos Stern, "as a dictator responsible to no one either in theory or practice". Halm also considers that it was Kutayfat who at this point eliminated al-Tayyib.


## Rise to the throne and the Hafizi–Tayyibi schism
The Fatimid elites refused to accept these changes. Members of al-Amir's bodyguard assassinated Kutayfat in a counter-coup on 8 December 1131 and released Abd al-Majid from his prison. This restoration of the dynasty was thereafter commemorated annually, up until the end of the Fatimid Caliphate, as the 'Feast of Victory' (ʿĪd al-Naṣr).
Given his lack of legitimation, as he was not in the line of succession to al-Amir, Abd al-Majid initially continued ruling as a regent. The first coins of his reign were struck with him still bearing the title of walī ʿahd al-muslimīn. Whether Abd al-Majid had had designs on the caliphate or not, the lack of a direct heir meant that the continuation of the Fatimid dynasty and the Isma'ili imamate required that he succeed as imam and caliph, since according to Isma'ili doctrine, "God does not leave the Moslem Community without an Imam to lead them on the right path". This was done in a decree (sijill) on 23 January 1132, whereby Abd al-Majid assumed the title al-Ḥāfiz li-Dīn Allāh ('Keeper of God's Religion'). For the first time in the Fatimid dynasty, power was not passed from father to son, creating a radical departure from established practice that had to be addressed and justified. Thus the sijill proclaimed al-Hafiz's right to the imamate, likening it to the sun, which had been briefly eclipsed by al-Amir's death and Kutayfat's usurpation, but had now reappeared in accordance with the divine purpose. No reference to any son of al-Amir was made. Al-Hafiz claimed that he had—secretly—received the designation (naṣṣ) as successor by al-Amir, and that Caliph al-Mustansir had foreseen this event, and had called al-Hafiz's father as walī ʿahd al-muslimīn. Earlier examples of breaks in the direct succession of the imamate, chiefly the designation by Muhammad of his son-in-law Ali ibn Abi Talib, were brought up to buttress his claim.
Al-Hafiz's highly irregular accession and claims to the imamate were largely accepted by the Isma'ili faithful in the Fatimid domains in Egypt, Nubia, and the Levant, but rebuffed by some communities. Most notably, this was the case in the only other major Isma'ili realm, Yemen, where the hitherto staunchly pro-Fatimid Sulayhid dynasty broke up. The Sulayhid queen, Arwa, upheld the rights of al-Tayyib, whose birth had been announced to her in a letter by al-Amir, while the regional dynasties of the Hamdanids and the Zurayids recognized al-Hafiz's claims.
The issue was not merely political, but, given the pivotal role of the imam in the Isma'ili faith, also intensely religious. In the words of Stern, "on it depended the continuity of institutional religion as well as the personal salvation of the believer". A similar succession dispute in 1094/5 had already led to the disastrous Musta'li–Nizari schism: after the death of al-Mustansir, al-Afdal Shahanshah had raised al-Musta'li Billah to the caliphate instead of his older brother, Nizar, leading to a brief civil war and Nizar's execution. While al-Musta'li had been recognized by the Fatimid establishment and the Isma'ili communities dependent on it in Syria and Yemen, the Iranian Isma'ilis had largely adopted Nizar's claims to the imamate and broken off their relations with the Fatimids. The Nizaris remained implacably opposed to the Musta'li regime in Cairo, and their agents (the 'Assassins') were blamed for the murder of al-Afdal in 1121, and of al-Amir. Al-Hafiz's accession in turn produced a major schism in the Musta'li branch of Isma'ilism, between the adherents of the imamate of al-Tayyib (the 'Tayyibis') pitted against supporters of al-Hafiz and his successors (the 'Hafizis'). As Stern emphasizes, in both cases the issue was "not so much the person of the claimant that weighed with his followers; they were not moved by any superior merits of Nizar as a ruler (this is, of course, obvious in the case of the infant al-Tayyib)—it was the divine right personified in the legitimate heir that counted".
Thus, by 1132 the once unified Isma'ili movement had split into three branches: the Hafizi, which now became the official doctrine of the Fatimid realm, the Tayyibi, which mostly survived in the mountains of Yemen, and the Nizari. Apart from Yemen, Tayyibi supporters existed in Egypt as well as in the Levant, but they were apparently heavily persecuted by the Fatimids. The Hafizi branch, inextricably bound to the Fatimid regime, survived in Egypt until the fall of the Fatimid Caliphate in 1171, but it disappeared quickly after, unlike its two rivals, which survive to the present day. The last holdout of Hafizi Isma'ilism was Yemen, where significant communities survived into the 13th century.


## Reign
The accession of al-Hafiz signalled the restoration of the Fatimid dynasty and the figure of the caliph, but the preceding events had shaken the regime's foundations. The new caliph enjoyed little authority over the army, and al-Hafiz's reign was marred by chronic instability, having to fend off rebellions and challenges to his legitimacy from ambitious warlords, and even from within his own family. To bolster his legitimacy, al-Hafiz resorted, among other things, to converting the Shi'a festival of Ghadir Khumm into a festival celebrating the Fatimids. Despite his weak position, al-Hafiz succeeded in remaining on the throne for almost two decades.
Al-Hafiz continued the practice of appointing viziers to run the government in his name, but the power concentrated into the office's hands since the days of Badr al-Jamali made it a danger even to the caliph, and al-Hafiz paid particular attention to his viziers' activities. Indeed, for the last decade of his reign, he did not appoint any viziers, but instead relied on high-ranking clerks as ad hoc directors of government affairs.


### Vizierate of Yanis and first personal regime, 1132–1134
His first vizier was the Armenian Yanis, a former military slave of al-Afdal and thus a prominent member of the same army factions that had raised Kutayfat to power. Yanis had already occupied high offices under al-Amir, including chamberlain (ṣāḥib al-bāb), a post almost as powerful as the vizierate. To enforce his own authority, he executed half of al-Amir's bodyguard and formed a private army, the Yānisiyya. His growing power alarmed the Caliph. When Yanis died in late 1132, after nine months in office, it was rumoured that the Caliph had had him poisoned.
After Yanis' death, the powerful position of vizier was deliberately left vacant. Al-Hafiz also dismissed Yuhanna ibn Abi'l-Layth, the long-serving head of the dīwān al-taḥqīq ('bureau of verification'), responsible for overseeing the financial administration. The Caliph used the opportunity to enlist the support of the ashrāf families (those claiming descent from Muhammad) by appointing the sharīf Mu'tamid al-Dawla as head of the dīwān al-taḥqīq, and his brother as naqīb al-ashrāf ('head representative of the ashrāf'). Al-Hafiz also had to confront a revolt of troops in the eastern Nile Delta, as well as an unexpected danger: al-Husayn, one of the sons of Nizar (the eponymous cause of the Nizari schism) who had fled to the Maghreb upon his father's execution, left his exile to return to Egypt. He gathered an army, but al-Hafiz successfully bribed one of his officers to assassinate him before he reached the country.
At the same time, the Caliph sought to bolster Fatimid credentials in the eyes of the Muslim world by once again taking up the mantle of champions of the jihād against the Crusader Kingdom of Jerusalem, as had been the case under al-Afdal. Taking advantage of the revolt of Hugh II of Jaffa against King Fulk of Jerusalem (r. 1131–1143), after a long hiatus caused by the loss of Tyre in 1124, the Fatimids resumed their attacks on the Crusader territories from their stronghold at Ascalon. As a result, Fulk was forced to construct a series of new castles—Chastel Arnoul (1133), Beth Gibelin (1137), Ibelin (1141), and Blanchegarde (1142)—to protect the Jaffa–Jerusalem road and provide security for Western settlers. These fortresses shifted the balance in the Crusaders' favour, as they forced the Fatimid garrison of Ascalon into a defensive stance. With the fortification of Gaza in 1150, Ascalon was entirely cut off by land, paving the way for its capture by the Crusaders in 1153.


### Vizierates of al-Hafiz's sons, 1134–1135
In 1134, al-Hafiz appointed his own son and designated heir, Sulayman, as vizier. A move designed to further strengthen the dynasty, it backfired disastrously when Sulayman died two months later, thereby once more throwing doubt on the supposed infallibility of the caliph-imam. Sulayman's younger brother Haydara was immediately appointed as heir and vizier, but this provoked the jealousy of another of al-Hafiz's sons, Hasan.
Hasan won the backing of the Juyūshiyya, a regiment of apparently Armenian origin established by Badr and al-Afdal that had been the pillar of their power and that had also supported Kutayfat. The Caliph and Haydara were backed by the Black African regiment of the Rayḥaniyya. This dissension appears to have had religious motivation as well, as Hasan and his followers are said to have backed Sunnism and attacked Isma'ili preachers. On 28 June, the Juyūshiyya defeated the Rayḥaniyya, forcing Haydara to flee to the palace, which was now besieged by Hasan's troops. Faced with this unprecedented situation, al-Hafiz backed down and on 19 July, he appointed Hasan as vizier and heir. As the historian Michael Brett comments, al-Hafiz had effectively appointed his son "in opposition to himself".
To secure his position, Hasan organized a private militia, the ṣibyān al-zarad, with which he terrorized the elites.  Al-Hafiz instigated the Black African garrison of Upper Egypt to try and depose his son, but again Hasan's men emerged victorious. In the end, it was Hasan's tyrannical rule that caused his downfall. His brutal treatment of his enemies, the executions of prominent men and the confiscation of property, cost him whatever support he may have had.  It was said that as many as 15,000 people were killed in the turmoils caused by Hasan's rule.
Following the murder of several senior commanders, the army rose in revolt in March 1135. Hasan fled to the caliphal palace, where al-Hafiz placed him under arrest. The troops then assembled at the square before the palace and demanded his execution, otherwise threatening to set fire to the palace. Al-Hafiz called to his rescue the governor of the Gharbiyya province (the western Nile Delta), Bahram al-Armani. Before Bahram could arrive in the capital, the Caliph bowed to the soldiers' demands and had his son poisoned by his Jewish physician.


### Vizierate of Bahram, 1135–1137
Arriving in Cairo soon after the murder of Hasan, Bahram al-Armani, although a Christian, was named vizier on 4 April 1135 and received the title of 'Sword of Islam' (Sayf al-Islām). The appointment of a Christian to the post of vizier provoked much opposition among the Muslims, as the office was seen as the representative of the imam-caliph, and entailed ritual roles in Islamic ceremonies and precedence over Muslim clerics. Al-Hafiz persisted with his appointment, but gave Bahram a dispensation to absent himself from ritual ceremonies, in which the vizier's role was taken by the chief qāḍī. He also did not receive those customary titles of the Fatimid viziers that implied control over the Muslim religious establishment (qāḍī al-quḍāt and dāʿī al-duʿāt).
The Muslim population continued to oppose Bahram because he showed favour to Christians of all denominations, permitted the conferment of privileges on churches and the construction of new ones, and encouraged Armenian immigration, which in a short time is said by medieval sources to have reached 30,000 people. His brother, Vasak, was appointed governor of Qus in Upper Egypt, and his government was blamed by contemporaries for being tyrannical towards the local population. In foreign policy, Bahram's tenure inaugurated a period of peace, since the Crusader states of the Levant were occupied with the growing threat of Zengi, the Turkish atabeg of Mosul. Bahram even presided over the release of 300 captives held since the Battle of Ramla in 1102. The vizier appears to have entertained good relations, and possibly formed an alliance, with King Roger II of Sicily.
In the meantime, the Muslim backlash against Bahram grew. His post as vizier was already considered an insult, but the favour shown to Christians, the Armenian immigration, and his close relations with Christian powers further inflamed passions. Ridwan ibn Walakhshi, the Caliph's former gaoler, emerged as the movement's leader. Ridwan was a Sunni who had risen to be one of the leading military commanders under al-Amir, and now held the position of ṣāḥib al-bāb. Bahram tried to dispose of him by sending him to govern Ascalon in May 1135, but there Ridwan busied himself with blocking Armenian immigration, earning plaudits from the Muslim public opinion in Cairo. As a result, Bahram recalled him in November 1136 and sent him to govern his own former province at Gharbiyya. The move backfired, as Ridwan was now placed in possession of an independent power base. Leading Cairene officials began making contact with him, and Ridwan did not hesitate to preach jihād against Bahram from the pulpit of the mosque. Finally, in early 1137 Ridwan raised an army from the local Bedouin and marched on Cairo. Bahram's Muslim soldiers deserted him, and on 3 February he fled Cairo with 2,000 Armenian soldiers, making for Qus. After his departure, an anti-Armenian pogrom broke out in the capital, and even the vizieral palace was plundered.
At Qus, Bahram found his brother killed and defiled by the local townfolk. In revenge, Bahram plundered the city, but resisted calls to torch it so as not to fully alienate the caliph. He then made for Aswan on the southern border of the Fatimid realm—some sources claim that he had intended to found a new realm allied with the Christian kingdoms of Nubia to the south—but the local governor barred his gates to him, and Bahram was forced to retreat to Akhmim. There a letter from al-Hafiz reached him, offering lenient terms: he could choose either a governorship at Qus, Akhmim, or Asyut, but could keep only a fraction of his followers, or he could enter a monastery near Akhmim, with a letter of protection (amān) for himself and his relatives. Bahram chose the latter.


### Regime of Ridwan, 1137–1139
The Caliph's leniency towards Bahram is not surprising, as the Christian vizier was not nearly as threatening to his own position as the Sunni Ridwan ibn Walakhshi, who "promised to be a second Nasir al-Dawla, threatening to turn the country over, not to Twelver Shi'ism like Kutayfat, but to Sunnism". Indeed, when Ridwan took office on 5 February 1137, his titles reflected his dangerously powerful position. The new vizier was, like Bahram, the 'Sword of Islam', and once again, being a Muslim, head of the qāḍīs (qāḍī al-quḍāt) and the dāʿīs ('dāʿī al-duʿāt). Instead of 'Most Mighty and Excellent Lord' (al-sayyid al-ajall al-afḍal), he was now 'Most Excellent King' (al-malik al-afḍal), signalling his status as a monarch effectively independent of the imam–caliph. Ridwan's appointment thus marks the culmination of a process that made the Fatimid viziers into sultans, similar to the relationship of the Seljuk rulers vis-à-vis the Abbasid caliphs since the time of Tughril (r. 1037–1063).
Now vizier, Ridwan launched an anti-Christian persecution. Christian officials were replaced with Muslims, their properties confiscated, and some were executed. Restrictive and discriminatory sumptuary laws and regulations were introduced for Christians and Jews, such as requiring them to wear specific clothes and to dismount when passing by a mosque, or prohibiting them from riding horses, but only donkeys and mules. The poll tax (jizya) was redefined, and was now required to be paid to a bench set at the height of the head, as a sign of inferiority. Bahram's Armenian troops were disbanded, either settled as peasants or allowed to leave Egypt and return to their homeland. At the same time, Ridwan promoted Sunnism: a Shafi'i madrasa was established on the Syrian model in Alexandria, where Sunnism was more widespread than the capital. Ridwan also continued correspondence with the Burids, a Turkish dynasty that ruled southern Syria, particularly Shams al-Dawla Muhammad of Baalbek, for a common front against the Crusaders, but also possibly with the aim of using the Sunni Syrians to unseat the Fatimid dynasty.
In 1138 Ridwan attempted to remove al-Hafiz from power altogether by consulting a Sunni (the head of the Alexandria madrasa, Ibn Awf), a Twelver (Ibn Abi Kamil), and an Isma'ili jurist (the chief dāʿī Isma'il ibn Salama) on the possibility of deposing al-Hafiz. Their answers were fairly predictable: Ibn Abi Kamil argued that the claim to the imamate by al-Hafiz and his ancestors was false, Ibn Salama supported the Caliph, and Ibn Awf took a more cautious stance and advised that the deposition should be handled in accordance with religious law. Ridwan began arresting and executing members of the Caliph's entourage, while al-Hafiz demonstratively recalled Bahram from exile and allowed him to settle in the palace. Ridwan in turn appeared in public on the Eid al-Fitr on 31 May wearing a robe in a style normally reserved for monarchs.

Matters came to a head on 8 June, as al-Hafiz, enthroned atop the Golden Gate of the palace, engaged in a heated exchange with Ridwan below. The vizier then ordered the palaces surrounded by troops, and presented one of the Caliph's sons, aiming to place him on the throne. This failed as the palace remained closed to him, and due to the resistance of Ibn Salama, who insisted that only the imam could sanction his successor by conferring naṣṣ upon him. This impasse allowed al-Hafiz to regain the initiative. The turncoat son and his followers were killed, and on 12 June a group of twenty men of the caliphal bodyguard entered the city through the Bab Zuwayla gate shouting "al-Hafiz, the Victorious" (al-Ḥāfiz yā manṣūr). They were quickly joined by the populace and the bulk of the army, which rose in revolt against Ridwan. It was only with the assistance of his brother and nephew, and some loyal troops of the Rayḥaniyya, that Ridwan was able to break through and escape the city via the Bab al-Nasr (Victory Gate). The vizier's palace was once more plundered by the mob behind him.
Aided by the Bedouin in his employ, Ridwan fled to Ascalon and thence to the Burid domains. The Burid governor of Salkhad, Kumushtakin, gave him a force of Turks, with whom he returned to Egypt. Rallying the Bedouin around him, he marched on Cairo, but was repulsed in front of the city gates on 28 August 1139. A month later, al-Hafiz led his army, comprising the Ḥāfiziyya and Āmiriyya regiments and his own bodyguard, to defeat Ridwan's forces. Ridwan fled to Upper Egypt, but soon had to surrender himself to the Caliph's forces in exchange for an amān. Al-Hafiz had Ridwan interned in the palace, in the room next to Bahram's.


### Return to personal rule, 1139–1149
After Ridwan's downfall, al-Hafiz offered to reappoint Bahram as vizier, but the latter refused. He remained al-Hafiz's closest aide, however, and on his death in November 1140, al-Hafiz participated in the funeral cortège in person. For the remainder of his reign, al-Hafiz did not appoint another vizier, but rather chose secretaries (kātib) to lead the administration. At some point in 1139/40, the Berber Salim ibn Masal was appointed as leading minister, but the title of vizier was deliberately avoided, and he was instead titled 'supervisor of affairs' (nāẓir fi'l-umūr) or 'supervisor of the public interests' (nāẓir fi'l-maṣāliḥ). Ibn Masal would be named vizier only after al-Hafiz's death. This was a deliberate attempt to reverse the progressive transformation of the vizierate into a sultanate: unlike the viziers, the secretaries were civilian bureaucrats without ties to the army, and often non-Muslims as well, and hence utterly dependent on the Caliph.
The first of these secretaries was the Egyptian Christian Abu Zakari, who had been appointed as 'supervisor of the bureaus' (nāẓir fi'l-dawāwīn, likely indicating the head of the dīwān al-taḥqīq) by Bahram and been dismissed and exiled by Ridwan. Al-Hafiz restored him to his position, and awarded him the title 'Protege of the Caliphate' (ṣanīʿat al-khilāfa). He appears to have used his position as head of the fiscal administration to contract for tax revenues and appropriate the surplus income for himself. As a result, in 1145 he was arrested and executed at the Caliph's orders along with his father and brother. Muslim writers denigrated Abu Zakari as 'the Slit-Nosed One' (al-akhram), twisting his honorific al-akram ('the Most Noble One'). This anti-Christian animus perhaps explains why his two successors were both Muslim qāḍīs who had served under Ridwan. The first, Abu'l-Karam al-Tinnisi, received the title of 'the Successful One' (al-Muwaffaq), and held the post for two years, until September 1147. He was replaced by Muhammad ibn al-Husayn al-Tarabulusi, surnamed 'the Chosen One' (al-Murtaḍā). Al-Tarabulusi was also appointed head of the chancery, and given quasi-vizieral prerogatives: he was allowed to wear the tail of his turban (ḥanak) in a style reserved for palace eunuchs, and attended the caliph at the Friday prayer.
In foreign affairs, al-Hafiz's final decade was largely peaceful. Both the Fatimids and the Kingdom of Jerusalem were focused on internal troubles, and the Crusaders were preoccupied with Zengi. In April/May 1141, Crusader knights appeared before Ascalon, but were chased away by the Fatimid garrison. In 1142/3, Fatimid envoys visited the court of Roger II of Sicily. Roger pursued expansionist plans against the former Fatimid domains in Ifriqiya, now ruled by the Zirid dynasty, and his fleet had recently captured the old Fatimid capital of al-Mahdiya there. Despite the possible danger posed by the Christian expansion into North Africa, and incidents where Norman warships captured Egyptian merchant vessels, relations remained cordial. The chronicler Romuald of Salerno even records the conclusion of a commercial treaty between Egypt and Sicily in 1143. According to Halm, Roger's decision to abstain from the Second Crusade (1147–1150) may have played a role in maintaining friendly relations until both monarchs died. The historian Jeremy Johns points out that while the Fatimids had long lost the ability to intervene directly in Ifriqiya, they adopted a "laissez-faire" attitude towards Norman expansion since the kings of Sicily, a "trading partner of proven worth", promised "restoration of law and order along the North African coast", which would be of benefit to Egyptian commerce. Johns also points out that even many of the trade networks linking the Indian Ocean and Red Sea to Egypt and the Mediterranean appear to have been in the hands of Sicilian and Ifriqiyan merchants at this time, which may further explain Cairo's interest in the Norman venture.
In 1139/40, al-Hafiz sent envoys to the Zurayid ruler of Aden, Ali ibn Saba ibn Abu'l-Su'ud, to formally invest him as dāʿī for Yemen. By the time the Fatimid envoy arrived, Ali had died, so the investiture passed to his brother and successor, Muhammad. Another embassy to Yemen is recorded in 1144, most likely again heading to Aden. In September 1147, a Fatimid embassy arrived in Damascus, apparently in an attempt to make common cause with its ruler, Unur, against the ambitions of Zengi's son, Nur al-Din. Given the continuing troubles in Egypt, however, any thought of a Fatimid intervention in Syria remained an impossibility.
The last years of al-Hafiz's reign were dominated by domestic challenges that laid bare the unstable foundations of his authority. In 1144/5, one of al-Hafiz's uncles, Abu'l-Husayn, tried to gain the support of the ṣāḥib al-bāb for his own bid to the caliphate, promising to make him vizier as a reward. The ṣāḥib al-bāb, Khumartash, informed al-Hafiz, who had his uncle thrown into prison. In 1146, the commander Bakhtiyar rebelled in Upper Egypt, but was defeated by a force of Luwata Berbers from the Western Desert. In May 1148, Ridwan managed to escape from his confinement in the palace, cross the Nile, and rally followers to his banner, including Bedouin, regular soldiers, and Luwata. With this army he marched once more on Cairo, defeated the Caliph's troops and pursued them into the city itself. Al-Hafiz barred the gates of the palace, but pretended to be cooperative, and even sent money when Ridwan asked for it to pay his men. At the same time, the Caliph selected ten Black African members of the caliphal bodyguard to assassinate Ridwan. Shouting "al-Hafiz, the Victorious", they attacked and killed him and his brother near the Aqmar Mosque. In 1149, another pretender, a supposed son of Nizar, gathered Berber supporters—Luwata and even some Kutama, once the mainstay of the early Fatimid dynasty—to attack Alexandria. The rebels scored a victory against the first army sent to confront them, but the rebellion was ended when al-Hafiz bribed the Luwata chieftains to withdraw with money and promises of land grants in the Nile Delta. The pretender's severed head was sent to Cairo. In 1149, the rival military factions, the Juyūshiyya and the Rayḥaniyya, once again clashed in the streets of Cairo, so that people were afraid to enter the capital. The Juyūshiyya emerged victorious and drove their opponents out of the city to Giza. These years were also ones of natural disasters. The Nile floods were particularly low in 1139, while famine and pestilence ravaged Egypt in 1142. In 1148, the Nile flood was too high, with the water reaching to the gates of Cairo.


## Death and legacy
Al-Hafiz died on 10 October 1149, of a severe intestinal colic. His survival on the throne through all the threats he had faced was remarkable, and he had managed to restore the caliph's personal control over the administration to an extent unseen for a century. But on his death he left behind a severely shaken regime, which survived mostly thanks to inertia and the vested interest of large sections of society in keeping it running. The Isma'ili mission, which had animated the early Fatimid expansion, had lost its drive, and the dynasty's legitimacy was increasingly challenged. The Fatimid empire during his reign had shrunk to Egypt, and the parts of Yemen and Makuria that recognized its overlordship. While the Fatimid cause flagged, beyond Egypt's borders, Zengi and Nur al-Din were building a militantly Sunni regime in Syria whose ideological zeal was making itself felt across the region. Enfeebled, Egypt would soon become the prize in the conflict between the Nur al-Din and the Crusaders, leading to the final collapse of the Fatimid dynasty.
Al-Hafiz was succeeded by the youngest and only surviving of his five sons, the 16-year-old Abu Mansur Isma'il, with the regnal name al-Zafir bi-Amr Allah. Al-Hafiz was the last Fatimid caliph who rose to the throne as an adult. The next three Fatimid imam-caliphs, until the end of the dynasty in 1171, were little more than puppet rulers, with real power lying in the hands of their viziers.


## Buildings
Al-Hafiz erected numerous shrines and mosques. Shrines to Alid saints were especially prominent among them, in an apparent effort to channel popular devotion to the Alids to bolster the Fatimid dynasty's weakened legitimacy.
In 1133, al-Hafiz erected the Mashhad of Sayyida Ruqayya, a shrine dedicated to a daughter of Ali ibn Abi Talib—but not by Fatimah, Muhammad's daughter—after she reportedly visited him in a dream. In 1138 the caliph undertook a major refurbishment of the al-Azhar Mosque, which established the keel-shaped arches and carved stucco decoration seen in the courtyard today, as well as the dome at the central entrance of the prayer hall. In the same year he also ordered the restoration of the dome over the dome, and a marble lining for the mihrab, of the al-Sayyida Nafisa Mosque. The Mausoleum of Ikhwat Yusuf is also attributed to the early reign of al-Hafiz on stylistic grounds, the decoration of its mihrab bearing close similarities with the work commissioned by al-Hafiz at the al-Azhar and the Mashhad of Sayyida Ruqayya.
During the last years of his reign, al-Hafiz commissioned the Mashhad of Yahya al-Shabih, a cenotaph for two sons of al-Qasim Abu Tayyib, a son of Muhammad ibn Ja'far al-Sadiq, as well as the Mausoleum of Muhammad al-Hasawati. From literary sources it is known that al-Hafiz also ordered restoration or construction for the shrines of the heads of other Alid saints: al-Husayn (now occupied by the reconstructed Al-Hussein Mosque), of Abraham, and of Zayd ibn Ali.


## Footnotes
## References
## Sources
Bianquis, Thierry (2002). "al-Ẓāfir bi-Aʿdāʾ Allāh". In Bearman, P. J.; Bianquis, Th.; Bosworth, C. E.; van Donzel, E. & Heinrichs, W. P. (eds.). The Encyclopaedia of Islam, Second Edition. Volume XI: W–Z. Leiden: E. J. Brill. pp. 382–383. doi:10.1163/1573-3912_islam_SIM_8067. ISBN 978-90-04-12756-2.
Brett, Michael (2017). The Fatimid Empire. The Edinburgh History of the Islamic Empires. Edinburgh: Edinburgh University Press. doi:10.1515/9781474421515. ISBN 978-0-7486-4076-8.
Canard, Marius (1965). "Fāṭimids". In Lewis, B.; Pellat, Ch. & Schacht, J. (eds.). The Encyclopaedia of Islam, Second Edition. Volume II: C–G. Leiden: E. J. Brill. pp. 850–862. doi:10.1163/1573-3912_islam_COM_0218. OCLC 495469475.
Canard, Marius (1971). "Ibn Maṣāl". In Lewis, B.; Ménage, V. L.; Pellat, Ch. & Schacht, J. (eds.). The Encyclopaedia of Islam, Second Edition. Volume III: H–Iram. Leiden: E. J. Brill. p. 868. doi:10.1163/1573-3912_islam_SIM_3288. OCLC 495469525.
Daftary, Farhad (2007). The Ismāʿı̄lı̄s: Their History and Doctrines (Second ed.). Cambridge: Cambridge University Press. ISBN 978-0-521-61636-2.
Dedoyan, Seta B. (1997). The Fatimid Armenians: Cultural and Political Interaction in the Near East. Leiden, New York, and Köln: Brill. doi:10.1163/9789004492646. ISBN 90-04-10816-5.
Güner, Ahmet (1997). "Hâfız-Lidînillâh". TDV Encyclopedia of Islam, Vol. 15 (Hades – Hanefî Mehmed) (in Turkish). Istanbul: Turkiye Diyanet Foundation, Centre for Islamic Studies. pp. 108–110. ISBN 978-975-389-442-5.
Halm, Heinz (2014). Kalifen und Assassinen: Ägypten und der vordere Orient zur Zeit der ersten Kreuzzüge, 1074–1171 [Caliphs and Assassins: Egypt and the Near East at the Time of the First Crusades, 1074–1171] (in German). Munich: C. H. Beck. doi:10.17104/9783406661648-1. ISBN 978-3-406-66163-1. OCLC 870587158.
Johns, Jeremy (1987). "Malik Ifrīqiya: The Norman Kingdom of Africa and the Fāṭimids". Libyan Studies. 18: 89–101. doi:10.1017/S0263718900006865. S2CID 163054015.
Madelung, W. (1971). "Imāma". In Lewis, B.; Ménage, V. L.; Pellat, Ch. & Schacht, J. (eds.). The Encyclopaedia of Islam, Second Edition. Volume III: H–Iram. Leiden: E. J. Brill. pp. 1163–1169. doi:10.1163/1573-3912_islam_COM_0369. OCLC 495469525.
Magued, A. M. (1971). "al-Ḥāfiẓ". In Lewis, B.; Ménage, V. L.; Pellat, Ch. & Schacht, J. (eds.). The Encyclopaedia of Islam, Second Edition. Volume III: H–Iram. Leiden: E. J. Brill. pp. 54–55. doi:10.1163/1573-3912_islam_SIM_2612. OCLC 495469525.
Stern, S. M. (1951). "The Succession to the Fatimid Imam al-Āmir, the Claims of the Later Fatimids to the Imamate, and the Rise of Ṭayyibī Ismailism". Oriens. 4 (2): 193–255. doi:10.2307/1579511. JSTOR 1579511.
Walker, Paul E. (1995). "Succession to Rule in the Shiite Caliphate". Journal of the American Research Center in Egypt. 32: 239–264. doi:10.2307/40000841. JSTOR 40000841.
Walker, Paul E. (2017). "al-Ḥāfiẓ li-Dīn Allāh". In Fleet, Kate; Krämer, Gudrun; Matringe, Denis; Nawas, John; Rowson, Everett (eds.). Encyclopaedia of Islam (3rd ed.). Brill Online. doi:10.1163/1573-3912_ei3_COM_30176. ISSN 1873-9830.
Williams, Caroline (1985). "The Cult of ʿAlid Saints in the Fatimid Monuments of Cairo, Part II: The Mausolea". Muqarnas. 3: 39–60. doi:10.2307/1523083. JSTOR 1523083.
Williams, Caroline (2018). Islamic Monuments in Cairo: The Practical Guide (Seventh ed.). Cairo and New York: American University in Cairo Press. ISBN 978-977-416-855-0.