Al-Qa'im (Fatimid caliph)

Abū al-Qāsim Muḥammad ibn ʿAbd Allāh (أبو القاسم محمد ابن عبد الله; March/April 893 – 17 May 946), better known by his regnal name al-Qāʾim (القائم) or al-Qāʾim bi-Amr Allāh (القائم بأمر الله), was the second caliph of the Fatimid dynasty, ruling in Ifriqiya from 934 to 946. He was the twelfth Isma'ili Imam, succeeding his father Abd Allah al-Mahdi Billah ((r. 909 – 934)).

Origin
The future al-Qa'im was born in the Syrian town of Salamiyah in March or April 893, with the birth name Abd al-Rahman. Abd al-Rahman's father was Sa'id ibn al-Husayn, the future Caliph Abd Allah al-Mahdi Billah. Abd al-Rahman's mother was Sa'id's paternal cousin, the daughter of Abu Ali Muhammad, known as Abu'l-Shalaghlagh, who had fostered Sa'id when he became orphaned as a youth; her name is not recorded.

Sa'id, like Abu'l-Shalaghlagh before him, was the leader of the clandestine Isma'ili missionary network, the ('invitation, calling'), ostensibly propagating the return of a hidden imam, Muhammad ibn Isma'il, as the, the Islamic messiah. Sometime before 899, Sa'id began claiming that he was the actual hidden imam, descended from a line of hidden imams; and that Muhammad ibn Isma'il had been only a fiction and a cover name to mask their activities. These claims may even have begun before Sa'id assumed control of the : the family eunuch Ja'far reports in his memoirs that already Abu'l-Shalaghlagh had secretly claimed to a few senior agents the title of for Sa'id, and the title of  for the newly born Abd al-Rahman. These claims caused a schism in the Isma'ili movement in 899, between those who recognized Sa'id's claims to the imamate and those who rejected them and continued to await the return of Muhammad ibn Isma'il as the. The latter are generally known by the term "Qarmatians".

Flight to Sijilmasa
After Sa'id's revelation that he was the hidden imam, some of his most fervent followers launched a series of Bedouin uprisings in Syria against the Abbasid Caliphate. Sa'id had not been consulted beforehand, and the outbreak of these revolts put him in danger, as his identity and location were revealed to the Abbasid government. The Abbasids launched a manhunt against him, so Sa'id took Abd al-Rahman and a few other close members of his household and left Salamiyah for Ramla in Palestine. There the local governor, secretly an Isma'ili convert, hid them from the Abbasid pursuit. The Bedouin rebels, calling themselves 'Fatimids', seized control of much of Syria and established a Shi'a regime on behalf of their hidden master, but despite receiving several letters urging him to join them, Sa'id remained in hiding at Ramla. The rebels were finally defeated in November 903 by the Abbasid army, and their leader captured and interrogated.

This once again forced Sa'id to abandon Ramla for Fustat in Egypt, then ruled by the autonomous Tulunid dynasty. Sa'id, Abd al-Rahman, and their small entourage stayed there until January 905, when the Abbasids invaded the country and overthrew the Tulunid regime. Sa'id decided to move to the Maghreb, in the western fringes of the Muslim world, where one of his agents, the Abu Abdallah al-Shi'i, had converted the Kutama Berbers to the Isma'ili cause, and by 905 had achieved some victories against the autonomous Aghlabid dynasty that ruled Ifriqiya (modern Tunisia and eastern Algeria) under nominal Abbasid suzerainty. On the journey west one of the group's members, Abu Abdallah's brother Abu'l-Abbas Muhammad, was arrested, and the Aghlabids learned about the identity and the appearance of the group's members. As a result, the group skirted the Aghlabid territory along its southern borders and made for the oasis town of Sijilmasa in what is now eastern Morocco. Sa'id, Abd al-Rahman, and their small entourage settled in Sijilmasa, leading the comfortable life of wealthy merchants, for the next four years.

Heir-apparent and military commander
In March 909, the Kutama under Abu Abdallah al-Shi'i finally defeated the last Aghlabid army, forcing Emir Ziyadat Allah III into exile and capturing the capital of Ifriqiya, Kairouan, and the nearby Aghlabid palace city of Raqqada. Abu Abdallah installed a Shi'a government in the name of the absent and as yet unnamed imam, and as soon as the new regime was stabilized, left with his army to bring Sa'id and his family to Ifriqiya. Learning of the approach of the Kutama army, the emir of Sijilmasa had Sa'id questioned and put under house arrest along with Abd al-Rahman, but otherwise they were treated well. Their servants on the other hand were thrown into prison, and regularly whipped. On 26 August 909, the Kutama army reached Sijilmasa, and demanded the release of their captive imam. After brief clashes with the Midrarid troops, Emir al-Yasa fled his city, which was occupied and plundered. Mounted on horseback and dressed in fine clothes, Abd al-Rahman and his father were presented to the army, amidst shouts and tears of religious exaltation. On the next day, 27 August, Sa'id was enthroned and acclaimed by the troops.

The army remained at Sijilmasa for several weeks, during which delegations offering submission came from across the western Maghreb, before setting out for Ifriqiya on 12 October. Subduing some Berber tribes on its way, the army reached the Aghlabid palace city of Raqqada on 4 January 910. On the next day, Friday, 5 January 910, in the sermon of the Friday prayer, a manifesto hailing the return of the caliphate to its rightful possessors, the Family of Muhammad, was read, and the name and titles of the new ruler were formally announced: "Abdallah Abu Muhammad, the Imam rightly guided by God, the Commander of the Faithful". On the same occasion, Abd al-Rahman received a new name, Abu'l-Qasim Muhammad. Coupled with the new name of his father, this was the same name as the Islamic prophet Muhammad had borne: Abu'l-Qasim Muhammad ibn Abdallah. This was the name that had long been prophesied for the, and modern scholars suggest that the choice was a subtle ploy by the new caliph to shift the millennialist expectations of his followers onto his son.

Suppression of the anti-
The explanation by al-Mahdi that he was merely one in a series of imams rather than the messiah of the end times, and the reality of the new ruler as a man—a middle-aged merchant who loved the finer things in life—clashed with the doctrines that had been propagated by Abu Abdallah. The latter began questioning the claims of his master, and was joined by several of the most prominent Kutama chieftains who had led the Kutama campaign against the Aghlabids. Informed of their intentions, al-Mahdi struck first, and on 18 February 911, Abu Abdallah and Abu'l-Abbas Muhammad were assassinated by loyal Kutama soldiers in the caliph's own palace. They were soon followed by the other Kutama chieftains who had taken part in the conspiracy.

This did not quiet Kutama doubts, however: in April 912, a young boy, Kadu ibn Mu'arik al-Mawati, was proclaimed by some of the Kutama as the true, new s were appointed, and a new holy book written. Starting from Ikjan, the original centre of Abu Abdallah's mission, the revolt spread to the cities of Mila and Constantine, while a loyalist army sent against them was thrown back after many of the Kutama in its ranks defected.

In response, in April/May 912, al-Mahdi officially proclaimed Abu'l-Qasim Muhammad as heir-apparent, gave him the regnal name ('He who executes God's command'), and placed him in charge of the army sent to quell the revolt. On 21 June 912, the loyalist army decisively defeated the rebels near Mila. The anti- al-Mawati and the other rebel leaders were soon captured, and prominently featured in al-Qa'im's triumphal entry into Kairouan in autumn.

Campaigns against Egypt
Following the consolidation of Fatimid rule in Ifriqiya, al-Mahdi's first objective was Egypt, the gateway to Syria and Iraq, the old heartlands of the Islamic world and seat of his Abbasid rivals. Tripoli, the easternmost city of the Aghlabid domain, had submitted to the Fatimids following the fall of the Aghlabid emirate, but the local Hawwara Berbers quickly came to resent the overbearing behaviour of the Kutama soldiery, as well as the heavy tax demands placed upon them. A first uprising and siege of Tripoli in 910–911 was followed by a general revolt of the Hawwara in summer 912. The Fatimid governor of Tripoli fled, and all Kutama in the city were slaughtered. Al-Qa'im was put in charge of a combined land and naval expedition, laying siege to Tripoli until it capitulated in June 913. Al-Qa'im left one of the principal Kutama generals, Habasa ibn Yusuf, there, to prepare the further eastward expansion of the Fatimid empire. In January 914, Habasa led an army east, and captured Barqa, the capital of Cyrenaica.

First invasion of Egypt
Following this first success, on 11 July al-Qa'im left Raqqada at the head of another army and went east to assume command of the expedition. Al-Qai'm ordered Habasa to await his arrival at Barqa, but Habasa, driven by ambition, led his forces into Egypt, entering Alexandria on 27 August.

At Tripoli, the fortuitous presence of al-Qa'im and his men prevented an attack by a rebel fleet from Sicily, that had recently sacked Sfax further north. Al-Qa'im arrived in Alexandria on 6 November 914, where he imposed the Fatimid call to prayer, a Kutama governor, and an Isma'ili (judge). In early December, as the Nile floods withdrew and allowed the passage of armies along the river, the Fatimid army set out for Fustat in two columns: Habasa ahead, with al-Qa'im following behind. The Abbasid governor, Takin al-Khazari, refused calls to surrender, and instead called for aid from Baghdad and mobilized his forces to defend the river crossing at the pontoon bridge to Rawda Island and Giza. The Fatimid army tried to capture the bridge on 15 December, but was beaten back: Takin's Turkic horse-archers inflicted heavy casualties on the Kutama lancers. The Egyptian forces pursued the Kutama into the night, but during the pursuit the inexperienced levies fell into an ambush, saving the Fatimid army from a complete rout. Some of the Egyptians (Christian Copts and Muslims alike) corresponded with al-Qa'im, revealing the continued presence of an element of possible sympathizers and, according to Heinz Halm, possibly the presence of a Fatimid in Fustat.

Unable to cross the river to Fustat, al-Qa'im led a large part of his army around Takin's defences and into the fertile Fayyum Oasis, where they could find provisions. The Kutama initially plundered the area, but al-Qa'im restored order and imposed a regular tax regime on the inhabitants. At this point, al-Qa'im and Habasa, who had remained behind in command of the bulk of the Fatimid army at Giza, fell out when al-Qa'im ordered Habasa replaced. On 8 January 915, in a large-scale battle at Giza, the Fatimids were decisively defeated; Fatimid sources unanimously attribute this defeat to Habasa, who fled the battlefield, despite al-Qa'im's exhortations to stand firm. The pro-Fatimid accounts maintain that al-Qa'im launched three attacks on the enemy and caused many casualties, but these embellishments cannot hide the fact that the battle was a disaster: with his army collapsing, al-Qa'im retreated to Alexandria, which he entered on 23 January.

Despite the setback, in his letters to his father, and the surviving sermons that he delivered in Alexandria, al-Qa'im appears not to have lost confidence in his ultimate success. At Alexandria, he held a number of Friday prayer sermons, propagating the Isma'ili and Fatimid cause. For a while he also engaged in negotiations with some Egyptian defectors, who asked for from al-Qa'im, and raised the prospect of the capitulation of Fustat. It appears that al-Qa'im himself was not entirely convinced of the sincerity of such proposals, which became impossible when the Abbasid commander-in-chief Mu'nis al-Muzaffar arrived at Fustat in April 915.

Soon after, Habasa with thirty of his closest followers deserted al-Qa'im and made for Ifriqiya; alarmed by this, al-Qa'im evacuated Alexandria hastily and without battle, leaving much of his armament and equipment behind. The city was quickly reoccupied by the Abbasids. Al-Qa'im arrived at Raqqada on 28 May 915. In his rear, Cyrenaica rose in revolt and overthrew Fatimid control; in Barqa, the entire Kutama garrison was killed.

Second invasion of Egypt
Despite the failure of the first attempt, preparations began immediately for a second assault on Egypt, starting with the recapture of Cyrenaica. This was accomplished with the surrender of Barqa after an 18-month siege, in April 917. Al-Qa'im set out from Raqqada on his second campaign against Egypt on 5 April 919. His vanguard arrived before Alexandria on 9 July 919, while al-Qa'im with the main body of his army came in September/October. The Abbasid governor of the city fled, and Alexandria surrendered without battle. Having already acknowledged Fatimid sovereignty during the first invasion and hence now considered in revolt, the city was sacked by the Fatimid troops.

As in 914, the Abbasid governor concentrated the few local forces at Giza, to defend the Nile crossing, until Baghdad could send reinforcements: once again, Mu'nis al-Muzaffar was entrusted with the high command, departing for Egypt on 23 February 920. Although al-Qa'im corresponded with several key figures in Fustat, including the former Tulunid vizier, Abu Bakr Muhammad ibn Ali al-Madhara'i, who kept him informed of the Abbasid garrison's state, he made no move to exploit the weakness of the Fustat garrison and storm Giza. It is possible that al-Madhara'i played a double game, trying to delay an attack until fresh Abbasid troops arrived. Al-Qa'im remained at Alexandria for the remainder of the year, as reinforcements continued to arrive from Ifriqiya. These included the Fatimid fleet, 80 ships strong under the eunuch Sulayman, but the Fatimid ships were decisively defeated by an Abbasid squadron under Thamal al-Dulafi on 12 March at Abukir.

After the failure of his navy and the arrival of Abbasid reinforcements, and with the supply situation in Alexandria worsening, al-Qa'im decided to repeat the manoeuvre of 914: on 30 July he left Alexandria and, bypassing Giza, took over the fertile Fayyum Oasis, which could provide provisions and a base of operations. As before, he proceeded to tax the inhabitants, as if he were the rightful ruler of Egypt. Another Kutama force took over Upper Egypt in spring 921 up to the Coptic bishopric of al-Ushmuniyya. Not only did this increase the area under taxation for al-Qa'im, but it also ended the grain supply of Fustat from there.

For an entire year, both sides avoided open conflict, and engaged rather in a diplomatic and propaganda battle. Mu'nis offered promises of safe-conduct (aman), as well as recognition of the Fatimids as autonomous rulers of Ifriqiya in the style of the Aghlabids, if al-Qa'im submitted to the Abbasid caliph. Al-Qa'im rejected these overtures in a letter that reiterated the Fatimids' claims to universal dominion as the rightful heirs of Muhammad. A fragment of a long poem by al-Qa'im, exhorting the inhabitants of Fustat to emulate the Ifriqiyan example and follow the rightful Fatimid da'wa, also survives, via a copy sent to Baghdad. At the same time, the Fatimid commander sent appeals to the two holy cities of Islam, Mecca and Medina, urging them to recognize the Fatimids' claims to sovereignty over the Islamic world. His requests were ignored.

The impasse was broken by the Abbasids in May/June 921: Thamal's fleet captured Alexandria, and then sailed down the Nile to support Mu'nis' attack on Fayyum. The Abbasid forces blockaded the sole connection of Fayym with the Nile at Illahun, cutting al-Qa'im and his men in the oasis from the rest of the country. Once the Abbasid forces began to advance into the oasis, on 8 July al-Qa'im ordered the retreat: all heavy equipment was left behind, while he and his men made their way through the desert to the coastal road to Barqa, an arduous march in which many perished.

Campaign against the Zenata Berbers
In the periphery of Aghlabid Ifriqiya, the nascent Fatimid regime faced significant challenges from the native Berber tribes, especially those living in the more mountainous areas, where the Aghlabids and their caliphal predecessors had failed to establish firm control. The main Fatimid stronghold outside Ifriqiya proper was Tahert, located some 300 km to the west. Its Fatimid governor, Masala ibn Habus, was a Miknasa Berber, which brought his tribe under the Fatimid banner. The efforts of the Miknasa to spread Isma'ilism in Ouarsenis, on the other hand, failed miserably, and their siding with the Fatimids led to another tribal group, the Zenata, to oppose the Fatimids under the leadership of Ibn Khazar and repeatedly attack Tahert.

Masala was killed by his rival in November 924, and was succeeded by his brother, Yasal. Although the latter was able to repel a Zenata attack on Tahert in 925, the defeat of a Fatimid relief army by Ibn Khazar encouraged other Berber tribes in the area to rise in revolt. This forced al-Mahdi to send al-Qa'im to deal with the revolt in person. The heir-apparent set out on 12 April 917, issuing a general call to arms, not only to the Kutama, but also to the Arab militia, which assembled at al-Aribus under Khalil ibn Ishaq al-Tamimi. Al-Qa'im then moved to Baghaya, from where he obliged the subdued Berber tribes, such as the Hawwara, Sadina, and Ajisa, to contribute men to his expedition; to ensure the latter's loyalty, the families of their chiefs were sent as hostages to Mahdiya. It was not until July, at Sétif, that the Kutama joined the army and the expedition was fully assembled.

From there, the chamberlain Ja'far ibn Ubayd, a former household slave of al-Mahdi at Salamiya, subdued the Kiyana tribe in the Hodna Mountains. Al-Qa'im founded a new city, named al-Muhammadiya (modern Msila) after himself, in the nearby plain, to cement Fatimid control over the area. One of the earliest Isma'ili partisans, Ali ibn Hamdun al-Andalusi, was tasked with completing its construction, and was made its first governor. Ziri ibn Manad, the leader of another Berber tribe, the Sanhaja, also offered his submission to al-Qa'im at this time.

In September, al-Qa'im entered the Zenata lands in the Zab Mountains. The Fatimid army moved about, trying to deny the Zenata food and pasture, and pursuing Ibn Khazar. Al-Qa'im led cavalry troops in person trying to capture the elusive Zenata chieftain, but the latter managed to escape again and again, frequently in the nick of time. Conditions were hard: uninterrupted rainfall for over a month in December and January cut off communications with Mahdiya, where the court feared that the entire expedition was lost. On 29 January 928, the Fatimid army defeated the sedentary Matmata tribe in a large-scale battle and forced them to submit to Fatimid rule. In March al-Qa'im arrived before the last Zenata stronghold, Zabraqa. After a brief siege and bombardment with catapults, the fortified city was sacked. Al-Qa'im's victory dispatch prompted the circulation of a poem, where the al-Qa'im announces himself as the "Son of the Messenger of God" who is about to "roam throughout God's earth...to Egypt and Iraq, and afterwards I shall concern myself with Baghdad".

The army then returned to Tahert, where a strong garrison was installed. On 20 October al-Qa'im began his return to Ifriqiya; he and his army received a triumphal reception at Mahdiya on 1 November. The campaign was hailed as a great success in Fatimid propaganda, but was marred by the escape of Ibn Khazar, who fled into the deep desert; al-Qa'im's men, with their supplies dwindling, could not follow him. Already in the next year, the Zenata chieftain returned to threaten the Fatimids in the Zab region. In addition, al-Qa'im's return was at least partly due to concerns about his position: his oldest son, al-Qasim, had informed him that in his absence, one of al-Qa'im's half-brothers, Abu Ali Ahmad, had been permitted to play a leading role in public ceremonies. The motivation for this unusual move—whether as a result of palace intrigues or due to a genuine concern that al-Qa'im might be dead—and whether al-Mahdi truly intended to promote Ahmad as an alternative successor, remains unknown. Al-Qa'im's return consolidated his position, but the affair left a lasting rift between him and his father.

Other activities
As heir-apparent al-Qa'im is also mentioned as a frequent intermediary for making grievances known to his father, such as against the tyrannical behavior of the governor of Kairouan, Abu Sa'id al-Dayf, or bringing to the caliph's attention the antinomian tendencies of some of the more extremist Isma'ili faithful in Ifriqiya, who claimed that al-Mahdi was God incarnate.

Succession and the chief figures of the reign
Al-Mahdi died at Mahdiya on 4 March 934, after a period of illness. Al-Qa'im kept his death secret for a hundred days, before announcing a period of public mourning. As the designated (nass) successor of the imam-caliph, al-Qa'im did not face any opposition. Apart from the one occasion in 928, his numerous half-siblings by concubines—six sons and seven daughters—never played an important role, and al-Mahdi had deliberately kept them in the palace, not entrusting them with a gubernatorial or military command.

Apart from the lamentations of some veteran da'is that the death of al-Mahdi meant the end of any hope for the afterlife, the only challenge to the succession came from Tripolitania, where a certain Muhammad ibn Talut claimed to be a son of al-Mahdi and laid claim to the imamate and caliphate. He managed to rally a large following among the local Hawwara Berbers, before his deception was discovered and he was executed by his own followers. Otherwise the transition into the new reign was smooth, with al-Qa'im taking up residence in the caliphal palace of Mahdiya, where he spent the remainder of his life. He abandoned public appearances during festivals, and became so reclusive a figure that his character is virtually unknown to posterity.

Al-Qa'im largely kept his father's ministers in place. Abu Ja'far Muhammad ibn Ahmad al-Baghdadi served as head secretary and head of the postal service, in effect a quasi-vizier. The public treasury (bayt al-mal) was headed by Abu'l-Hasan Muhammad, a descendant of prominent early da'is on both sides. The chamberlain Ja'far ibn Ali, another former household slave from the days of Salamiya, headed the palace service. The main new figure of al-Qa'im's reign was Jawdhar, a palace eunuch of Slavic (Saqaliba) origin. He became the steward of al-Qa'im's palace at Mahdiya when the latter was still heir apparent, and after his master's accession was placed in charge of the private treasury and the clothing storehouses.

Stabilizing the Fatimid empire
Under al-Mahdi, the nascent Fatimid realm had expanded in three directions at once: against the Muslim "usurpers", the Abbasids in the east and the Umayyad Emirate of Córdoba in the west; while pursuing the holy war against the main Christian enemy, the Byzantine Empire, in the north, in Sicily and southern Italy. This expansion was ideologically driven: the Fatimid caliphs were not only the secular rulers of a state, but concurrently also Shi'a imams, at the head of the wide-ranging network of the , and thus challenging the Sunni Abbasids for the leadership of the entire Islamic world. Already in his inaugural proclamation, al-Qa'im's father had claimed a mandate to "conquer the world to East and West, in accordance with God's promise, from sinful rebels".

The Maghreb
Al-Qa'im thus inherited from his father a large empire, but one whose conquest was incomplete and unconsolidated. The new caliph inherited a major crisis in the western Maghreb (modern Morocco), where Fatimid rule had collapsed in 931/2 with the defection of the Fatimid viceroy, the Miknasa Berber chieftain Musa ibn Abi'l-Afiya, to the Umayyad camp. Al-Qa'im entrusted two Slavic officers, Sandal al-Fata and Maysur al-Fata, with reconquering the area: Sandal against the Emirate of Nekor, while Maysur marched on Fes. Sandal conquered Nekor and killed its ruler in September 936, before joining Maysur at Fes. The city surrendered after a seven-month siege, and its governors deported to Mahdiya. Maysur installed the Idrisids, who had been persecuted by Ibn Abi'l-Afiya, as Fatimid vassals, and launched a pursuit of the renegade Miknasa chieftain, but without success.

To help keep the unruly Zenata in check, at the same time, in 936, al-Qa'im gave permission to the Sanjaha leader, Ziri ibn Manad, for the construction of the fortified palace city of Achir, and provided construction materials and artisans for the purpose. This cemented the close relation and loyalty of the Zirids to the Fatimids. The caliph also reinforced the authority of his march-warden at Msila, Ali ibn Hamdun al-Andalusi, over the Banu Kamlan Berbers.

Sicily and the central Mediterranean
In the north, a truce had been concluded with the Byzantines in 931/2 in exchange for the regular payment of tribute to Mahdiya, which was adhered to even after al-Qa'im's succession. As a result, the Fatimids set their sights north. In June 934 a Fatimid fleet under Ya'qub ibn Ishaq al-Tamimi sacked the city of Genoa. It then raided the coast of Corsica and Sardinia, before returning in triumph to al-Mahdiya in August 935.

In Sicily, the local Arab and Berber settlers continued to resent the Kutama-dominated and tax-heavy Fatimid regime, and in April 937, the populace of Agrigento, mostly non-Kutama Berbers, expelled their governor and rose in revolt. The Fatimid governor of the island, Salim ibn Asad ibn Abi Rashid, sent an army of Kutama against the city under Abu Duqaq, but he was defeated, and the Agrigentans marched on the island's capital, Palermo. Salim managed to beat them back, but in September, Palermo too rose in revolt, forcing Salim to lay siege to his own capital.

Fresh troops arrived from Ifriqiya in October. Their commander, Khalil ibn Ishaq al-Tamimi, was named governor of Sicily and quickly subdued Palermo. Agrigento was besieged next, from March 938, but Khalil had to abandon the siege at the onset of winter and return to Palermo. This failure encouraged further uprisings in the interior. The rebels successfully requested assistance from the Byzantines, and Khalil was forced to ask for reinforcements from Ifriqiya.

Khalil retook Mazara and the rebellious towns of the interior in 939–940, and on 20 November 940, Agrigento followed suit. The last rebel strongholds held out a little while longer, but by September 941 the island was pacified and Khalil returned to Ifriqiya. The island was once again under Fatimid control, but devastated and depopulated. Khalil boasted of having killed one million people during his campaign, the cadastral registers were destroyed, thus making verification of the land tax impossible, many Sicilian Muslims were dispossessed and forcibly resettled, and many others fled to the Byzantine-controlled territories of southern Italy.

Third invasion of Egypt
In the east, at the time of al-Qa'im's accession the Abbasid Caliphate was entering its final decline after the murder of Caliph al-Muqtadir in 932. The chaos in the Abbasid metropolitan region of Iraq was also felt in the provinces, especially Egypt, where the ambitious general Muhammad ibn Tughj al-Ikhshid eventually took power.

Some commanders of the local garrison refused to accept this, however, and fled to Barqa, where they called upon al-Qa'im for assistance. Al-Qa'im may have been intending to invade Egypt either way, and it is likely that his father had made preparations for this purpose, but this development provided him an excellent opportunity: troops under the freedman Zaydan and Amir al-Majun were immediately sent to Barqa to join the rebels. Alexandria was easily captured in early March 936, but already at the end of the same month, the invasion army was defeated by al-Ikhshid's forces. The Fatimid forces were once again expelled from Alexandria, losing many who were taken prisoner, and withdrew to Barqa.

The establishment of a strong ruler in Egypt in the person of al-Ikhshid checked Fatimid ambitions for some time to come, but more importantly, in the next years the Fatimid regime was shake to its very core by a large-scale revolt which nearly brought the dynasty to its end. It was not until a generation after al-Qa'im's death, in 969, that the Fatimids finally succeeded in conquering Egypt.

Revolt of Abu Yazid
Abu Yazid was a schoolteacher of mixed Zenata Berber and Black African descent, and an adherent of the Ibadi Kharijite sect that had been predominant among the Ifriqiyan Berbers before the coming if the Fatimids. From 937 on, he began a clandestine agitation against the Fatimids at Tozeur. Denounced and imprisoned, he was sprung from prison by his followers and fled to the Hawwara tribes of the Aurès Mountains.

There he quickly won many followers to his cause, and was elected their leader. His movement tapped into both the anti-imperial traditions of the great Berber Revolt against the Umayyad Caliphate in the 740s, as well as the native messianic traditions that had been the foundation of al-Mahdi's caliphate. Abu Yazid's followers, however, rejected the Fatimids' claims to a hereditary imamate, and insisted on the election of their leader.

Start of the uprising and the fall of Kairouan
In February 944, Abu Yazid's followers descended from the mountains, taking the Fatimids by surprise. Al-Qa'im mobilized the Kutama soldiers, but the small and highly mobile bands of Abu Yazid eluded them, and were always able to escape back to the safety of the Aurès. During the summer, cities began surrendering to the rebels, and the first pitched battle between the Kharijites and the Kutama near Dougga ended in a Fatimid rout.

On 7 August 944, al-Aribus (ancient Laribus), the gate to the core of Fatimid Ifriqiya, surrendered in exchange for a letter of safety (aman) for its inhabitants; Fatimid officials and all adherents of Isma'ilism were explicitly excluded from it. Al-Qa'im mobilized four armies in response: one to defend the old Aghlabid palace city of Raqqada, one under Khalil ibn Ishaq al-Tamimi to secure the former capital and major city of Ifriqiya, Kairouan, one under the eunuch Bushra to the area of Béja, and the main army under Maysur al-Fata, which was to encamp midway between al-Mahdiya and Kairouan, ready to assist either.

These dispositions left the initiative to the rebels, who could attack the Fatimid commanders in isolation. Bushra was defeated and forced to withdraw to Tunis and then Sousse, opening the way to Kairouan. There, Khalil al-Tamimi resisted his officers' calls to march out and confront the rebel army, awaiting the arrival of the main Fatimid army under Maysur al-Fata, but the latter also hesitated to move decisively against the rebels. As a result, the disgruntled and unpaid soldiers of the local militia began deserting to the rebels, forcing Khalil to surrender on 14 October. Abu Yazid had him and the city's chief qadi executed. Abu Yazid completed his triumph by destroying Maysur's army in a surprise night attack on 29/30 October: Maysur was killed, and his army disintegrated. Shortly after, Sousse was sacked as well.

The mostly Maliki Sunni inhabitants of Kairouan, who greatly resented Fatimid rule, were initially supportive of Abu Yazid's takeover, but the unruly behaviour of his Berber followers and their rapacious behaviour quickly alienated them. Nevertheless, for the moment, they were prepared to tolerate Abu Yazid as the lesser evil, in their fight against al-Qa'im, the 'Imam of the Unbelievers'.

Siege of al-Mahdiya and the Fatimid counter-offensive
Fleeing from the Kharijites' advance, desperate Kutama soldiers and Fatimid adherents had flocked to al-Mahdiya, but al-Qa'im, determined to conserve supplies for the upcoming siege, had refused to admit them into the walls. Instead, the Fatimid ruler ordered a new wall and ditch constructed to cover the outer suburbs, behind which the refugees took shelter. The defence of the wall and its two gates was assumed by the Kutama and the loyal palace troops, composed of slave soldiers.

Abu Yazid arrived before the Fatimid capital on 9 January 945. The first attack on the city, on 20 January 945, reached the wall of the palace city, but was eventually pushed back. The city was placed under blockade, which lasted until 16 September 945. The Fatimid position was difficult, as the ships bringing in grain supplies from Sicily and Tripoli ran aground and were captured by the rebels, but Abu Yazid also faced problems. Most of his men were untrained peasants, who now returned to their fields, or out for plunder; the Kharijite leader could count firmly only on the Hawwara. As a result, the siege was not very effective, and Fatimid sallies sometimes found the enemy camp empty. Even during this period of danger, however, al-Qa'im refused to show himself in public, or to send one of his sons in his stead, despite the entreaties of his court.

The siege of al-Mahdiya was broken as a result of the defection of the Arab troops from al-Aribus, following a quarrel with the Kharijite Berbers. On 16 September, at the crucial point of a battle against a Fatimid sortie, the Arabs turned on their erstwhile allies. The rebel army suffered heavy losses, and Abu Yazid was forced to retreat to Kairouan. There, Abu Yazid found the atmosphere hostile. Some locals contacted the Fatimids, offering to hand the city and the rebel leader over; an assassination plot was discovered and averted; and riots erupted over the forcible abduction of the locals' daughters and concubines by the Kharijite soldiery, justified according to Kharijite doctrine that treated Muslims of other creeds as unbelievers. Abu Yazid was forced to promise to stop the practice, and departed Kairouan; thereupon the locals forcibly released many women who had been abducted.

Discontent with Abu Yazid's rule spread across other parts of Ifriqiya: Sousse rose in revolt and, assisted by a Fatimid fleet, overthrew Kharijite rule. Tunis, Béja and al-Aribus followed suit. During the following months, heavy fighting between Abu Yazid's and the Fatimid forces occurred at Tunis, which was captured and recaptured by both sides, and left almost completely destroyed. A similar fate befell Béja and al-Aribus. The veteran Fatimid partisan, Ali ibn Hamdun al-Andalusi, advanced from his stronghold of Msila against the Kharijites, but was defeated by Abu Yazid's son Ayyub and died of his wounds shortly after.

Seeking allies against the Fatimids, Abu Yazid sent some Kairouan notables as envoys to the Umayyads of Córdoba. After this first embassy was well received, Abu Yazid sent Ayyub to pledge allegiance to the Umayyad caliph Abd al-Rahman III, who in turn promised to send support. As the year was late and the sailing season over, however, the Umayyad fleet was set to sail in the next year. Seizing the initiative once more, Abu Yazid marched to recover control of Sousse, beginning a siege of the city on 13 January 946.

Death and succession
According to the official Fatimid accounts, al-Qa'im died on 17 May 946, and was succeeded by his son Isma'il, who became the new caliph as al-Mansur Billah ((r. 946 – 953)). The transition of power went smoothly, but was irregular, as Isma'il was not the oldest son of al-Qa'im. The fate of the firstborn son, al-Qasim, is unclear—he reportedly had died in the meantime, and the pro-Fatimid sources are at pains to stress that Isma'il had been formally designated as heir by his father; Jawdhar insists in his memoirs that he was the trustee of Isma'il's undisclosed nomination as his father's heir already at the time of al-Qa'im's own accession in 934. Nevertheless, the fact that the new ruler had all his uncles and half-brothers arrested and held under the auspices of Jawdhar has led modern historians of the Fatimid period, such as Heinz Halm and Michael Brett, to suspect that Isma'il's unheralded rise to power was the result of a palace intrigue headed by Jawdhar, with the participation of other figures from al-Qa'im's harem.

Regardless of its legality, Isma'il's succession was providential for the Fatimid state. He immediately went into the offensive against the rebels, and in short order relieved Sousse, recovered Kairouan, and defeated Abu Yazid' attempts to recapture it. Abu Yazid was pursued into the mountains by the Fatimids, led by their new ruler in person, and finally captured and executed in August 947. To avoid giving the rebels any advantage, Isma'il and his government hid the death of al-Qa'im, a task made easier by the reclusive life al-Qa'im had led. All public business and ceremonies were still conducted in al-Qa'im's name, and Isma'il acted ostensibly only as his heir-designate. Even the regnal name of al-Mansur ('the Victorious') was only publicly assumed after the final suppression of the uprising.

Family
He was married already at an early age, before his family left Salamiya. His wife, Umm Habiba, apparently was still a child when she accompanied him to the Maghreb. He also had six known concubines, of which one, Karima, became the mother of his successor al-Mansur.

Assessment
When he came to power, al-Qa'im was an experienced man: he had been entrusted with a share of public affairs fairly soon after his father's rise to the caliphate, and although his record as commander was mediocre, judging from the result of the Egyptian campaigns, al-Qa'im displayed some ability and resolve. Most of his reign was a period of peace for Ifriqiya, when scarcely any event is noted by the chroniclers; nevertheless, his legacy is dominated by the disastrous end of his reign, amidst the cataclysmic uprising of Abu Yazid.

The historian Farhat Dachraoui thus calls him "one of the less illustrious members of the dynasty", and points out that his "excessive taxation and religious persecution", in his attempt to consolidate his rule, actually ended up encouraging the Kharijite uprising of Abu Yazid. Dachraoui also criticizes his passive defensive strategy and the splitting of his forces, which gave Abu Yazid the initiative and allowed him to defeat them piecemeal. For Michael Brett, al-Qa'im's reclusive rule "[lost] the initiative of the revolution at home and abroad at a time when the world around was changing", failed to rise to the aspirations to universal rule awoken by his name and title, and ended in disaster.