stylistic:style_transfer, structural:expansion
Final decline

As the military viziers effectively became heads of state, the Caliph himself was reduced to the role of a figurehead. The reliance on the Iqta system also ate into Fatimid central authority, as more and more the military officers at the further ends of the empire became semi-independent.

Badr al-Jamali died in 1094 (along with Caliph al-Mustansir that same year) and his son Al-Afdal Shahanshah succeeded him in power as vizier. After al-Mustansir, the Caliphate passed on to al-Musta'li, and after his death in 1101 it passed to the 5-year-old al-Amir. Another of al-Mustansir's sons, Nizar, attempted to take the throne after his father's death and organized a rebellion in 1095, but he was defeated and executed that same year. Al-Afdal arranged for his sister to marry al-Musta'li and later for his daughter to marry al-Amir, hoping in this way to merge his family with that of the caliphs. He also attempted to secure the succession of his son to the vizierate as well, but this ultimately failed.

During al-Afdal's tenure (1094–1121) the Fatimids faced a new external threat: the First Crusade. Although initially both sides intended to reach an agreement and an alliance against the Seljuk Turks, these negotiations would eventually break down. First contact seems to have been established by the crusaders who sent in May or June 1097, on suggestion of Byzantine Emperor Alexios Komnenos, an embassy to al-Afdal. In return the Fatimids dispatched an embassy to the crusading forces which arrived in February 1098 during their siege of Antioch, witnessing and congratulating the crusaders on their victory against the Seljuk emirs Ridwan of Aleppo and Sökmen of Jerusalem as well as stressing their friendly attitude towards Christians. The Fatimid embassy stayed for a month with the crusading forces before returning via the harbour of Latakia with gifts as well as Frankish ambassadors. It is uncertain whether an agreement was reached but it seems that the parties expected to reach a conclusion in Cairo. Al-Afdal took then advantage of the crusader victory at Antioch to reconquer Jerusalem in August 1098, possibly to be in a better position in the negotiations with the crusaders. The next time both parties met was at Arqah in April 1099 where an impasse was reached in regard to the question of ownership over Jerusalem. Following this, the crusaders crossed into Fatimid territory and captured Jerusalem in July 1099 while al-Afdal was leading a relief army trying to reach the city. The two forces finally clashed in the Battle of Ascalon in which al-Afdal was defeated. Nevertheless, the initial negotiations were held against the Fatimids and Ibn al-Athir wrote that it was said that the Fatimids had invited the crusaders to invade Syria.

This defeat established the Kingdom of Jerusalem as a new regional rival and although many crusaders returned to Europe, having fulfilled their vows, the remaining forces, often aided by the Italian maritime republics, overran much of the coastal Levant, with Tripoli, Beirut, and Sidon falling to them between 1109 and 1110. The Fatimids retained Tyre, Ascalon, and Gaza with the help of their fleet. After 1107, a new rising star rose through the ranks of the regime in the form of Muḥammad ʿAlī bin Fatik, better known as al-Maʾmūn al-Baṭā'iḥī. He managed to carry out various administrative reforms and infrastructural projects in the later years of al-Afdal's term, including the construction of an astronomical observatory in 1119. Al-Afdal's was assassinated in 1121, an act blamed on the Nizaris or Assassins, though the truth of this is unconfirmed.

Al-Baṭā'iḥī took al-Afdal's place as vizier, but unlike his predecessors he had less support in the army and was ultimately reliant on the caliph for power. In 1124 he lost Tyre to the Crusaders. He was also responsible for constructing a small but notable mosque in Cairo, the Al-Aqmar Mosque, which was completed in 1125 and has largely survived to the present day. That same year, however, Caliph al-Amir had him arrested, probably due to his failure to resist the Crusaders or due to the caliph's resentment of his wealth and power. Three years later he was executed. Al-Amir then ruled the Caliphate personally, briefly interrupting the long period of de facto rule by the caliph's viziers. Al-Amir himself was assassinated in 1130, probably by the Nizari Assassins.

Al-Amir apparently had a son born shortly before his death, known as al-Ṭayyib. One of Al-Amir's cousins (a grandson of al-Mustansir), Abd al-Majid, had himself appointed regent. Under pressure from the army, one of al-Afdal's sons, Abu Ali Ahmad (known as Kutayfāt), was appointed vizier with titles similar to al-Adal and Badr al-Jamali. Kutayfāt attempted to depose the Fatimid dynasty by imprisoning Abd al-Majid and by declaring himself to be the representative of Muhammad al-Muntazar, the "hidden" Imam awaited by Twelver Shi'as. The coup did not last long, as Kutayfāt was assassinated in 1131 by al-Amir's followers in the Fatimid establishment. Abd al-Majid was released and resumed his role as regent. In 1132, however, he declared himself to be the new Imam-Caliph, taking the title of al-Hafiz, sidelining the infant al-Ṭayyib and breaking with the tradition of the succession passing directly from father to son. Most of the Fatimid lands acknowledged his succession, but the Sulayhids in Yemen did not and broke away from the Caliphate in Cairo, recognizing al-Ṭayyib as the true Imam. This caused another schism between the Hafizi and Tayyibi branches of the Musta'li Isma'ilis.

In 1135 al-Hafiz was pressured by the Fatimid Armenian troops into appointing Bahram, a Christian Armenian, to the office of vizier. Opposition from Muslim troops forced him to leave in 1137, when Ridwan, a Sunni Muslim, was appointed vizier. When Ridwan began to plot the deposition of al-Hafiz, he was expelled from Cairo and later defeated in battle. He accepted a pardon from the caliph and remained at the palace. Al-Hafiz chose not to appoint another vizier, and instead took direct control of the state until his death in 1149. During this time, the fervor of the Isma'ili religious cause in Egypt had significantly faded, and political challenges to the caliph became more common. Sunni Muslims were also increasingly appointed to high posts. The Fatimid dynasty largely continued to survive due to the established common interests that many factions and elites had in maintaining the current system of government.

Al-Hafiz was the last Fatimid caliph to rule directly and the last one to ascend to the throne as an adult. The last three caliphs, al-Zafir (r. 1149–1154), al-Fa'iz (r. 1154–1160), and al-Adid (r. 1160–1171), were all children when they came to the throne. Under al-Zafir, an elderly Berber named Ibn Masal was initially vizier, per the instructions left by Al-Hafiz. The army, however, supported a Sunni named Ibn Sallar instead, whose supporters managed to defeat and kill Ibn Masal in battle. After negotiating with the women of the palace, Ibn Sallar was installed as vizier in 1150. In January 1153, the Crusader king Baldwin III of Jerusalem besieged Ascalon, the last remaining Fatimid foothold in the Levant. In April, Ibn Sallar was murdered in a plot organized by Abbas, his stepson, and Abbas's son, Nasr. As no relieving force arrived, Ascalon surrendered in August, on the condition that the inhabitants could leave safely for Egypt. It was on this occasion that the head of Husayn was allegedly brought from Ascalon to Cairo, where it was housed in what is now the al-Hussein Mosque. The next year (1154), Nasr murdered al-Zafir, and Abbas, now vizier, declared his 5-year-old son 'Isa (al-Fa'iz) the new caliph. The women of the palace intervened, calling on Ṭalā'i' ibn Ruzzīk, a Muslim Armenian governor in Upper Egypt, to help. Tala'i drove out Abbas and Nasr from Cairo and became vizier that same year. Afterwards he also conducted renewed operations against the Crusaders, but he could do little more than harass them by sea. Al-Fa'iz died in 1160 and Tala'i was assassinated in 1161 by Sitt al-Qusur, a sister of al-Zafir. Tala'i's son, Ruzzīk ibn Ṭalā'i', held the office of vizier until 1163, when he was overthrown and killed by Shawar, the governor of Qus.

As vizier, Shawar came into conflict with his rival, the Arab general Dirgham. The internal disorder of the Caliphate attracted the attention and meddling of the Sunni Zengid ruler Nūr ad-Dīn, who was now in control of Damascus and a large part of Syria, and of the King of Jerusalem, Amalric I. The Crusaders had already forced Tala'i ibn Ruzzik to pay them a tribute in 1161 and had made an attempt to invade Egypt in 1162. When Shawar was driven out of Cairo by Dirgham in 1163, he sought refuge and help with Nur al-Din. Nur al-Din sent his general, Asad al-Din Shirkuh, to seize Egypt and reinstall Shawar as vizier. The accomplished this task in the summer of 1164, when Dirgham was defeated and killed.

Shawar's remaining years continued in chaos as he made shifting alliances with either the King of Jerusalem or with Nur al-Din, depending on circumstances. In 1167 the Crusaders pursued Shirkuh's forces in to Upper Egypt. In 1168 Shawar, worried about the possible Crusader capture of Cairo, infamously set fire to Fustat in an attempt to deny the Crusaders a base from which to besiege the capital. After forcing the Crusaders to leave Egypt again, Shirkuh finally had Shawar murdered in 1169, with the agreement of Caliph al-Adid. Shirkuh himself was appointed as al-Adid's vizier, but he died unexpectedly two months later. The position passed to his nephew, Salah ad-Din Yusuf ibn Ayyub (known in the West as Saladin). Salah ad-Din was openly pro-Sunni and suppressed the Shi'a call to prayer, ended the Isma'ili doctrinal lectures (the majālis al-ḥikma), and installed Sunni judges. He finally and officially deposed al-Adid, the last Fatimid caliph, in September 1171. This ended the Fatimid dynasty and began the Ayyubid Sultanate of Egypt and Syria.