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 twelfth Isma'ili Imam and second caliph of the Fatimid dynasty, ruling in Ifriqiya from 934 to 946, succeeding his father Abd Allah al-Mahdi Billah ().
Born in March or April 893 in the Syrian town of Salamiyah, where his father, under the guise of a wealthy merchant, was leading the clandestine Isma'ili missionary network. Al-Qa'im and his father had to flee Salamiyah in 903 to avoid Abbasid persecution under the impact of a pro-Isma'ili revolt in Syria. Aided by sympathizers, the small group found refuge in to Ramla in Palestine and Fustat in Egypt, before turning west and making for the remote oasis town of Sijilmasa in what is now Morocco. While there, the Isma'ili missionary () Abu Abdallah al-Shi'i, who had converted the Kutama Berbers, overthrew the Aghlabid dynasty ruling in Ifriqiya and established the Fatimid Caliphate on behalf of al-Mahdi. After al-Mahdi's accession, al-Qa'im was officially made the designated successor and played a significant role during his father's reign as a military commander. He suppressed a Kutama revolt that broke out after the murder of Abu Abdallah al-Shi'i, captured Barqa, and led two invasions of Egypt, in 914–915 and 919–921. The Fatimids were able to capture Alexandria and threaten the capital, Fustat, but ultimately failed due to strong Abbasid resistance, logistical challenges, and the indiscipline of their troops. In 927, al-Qa'im led a campaign to suppress the Zenata Berbers in what is now central Algeria. He secured Fatimid control of Tahert, received the submission of the Sanhaja Berbers, and founded the city of al-Muhammadiya (modern Msila) as a stronghold to control the region.
After al-Mahdi's death in March 934, al-Qa'im succeeded without opposition, and mostly kept his father's ministers in place. A Fatimid naval raid sacked Genoa in northern Italy in the same summer, but the Fatimid position in the central Mediterranean was challenged by an anti-Fatimid revolt broke out in Sicily in 937 that was not suppressed until 940. In the west, the defection of the Berber commander Musa ibn Abi'l-Afiya upended Fatimid control over Morocco, and al-Qa'im's generals campaigned in the area without achieving lasting success. Another attempt to invade Egypt was launched in 935, but it was quickly defeated by the new local strongman, Muhammad ibn Tughj al-Ikhshid. The main event of al-Qa'im's reign was the great revolt led by the Kharijite preacher Abu Yazid, who mobilized Berber tribes as well as Arab townsmen against Fatimid rule, made unpopular by its strict taxation, unpopular Isma'ili doctrine, and the exactions of the unruly Kutama soldiery. The rebellion began in February 944 and rapidly gained momentum, resulting in the surrender of Kairouan and the siege of the Fatimid capital, al-Mahdiya. Al-Qa'im died on 17 May 946 in al-Mahdiya, with the rebellion still ongoing. His son, Isma'il, succeeded him as al-Mansur Billah and eventually quelled the uprising.
Early life 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". 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.
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 in 902. 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