The Ṭūlūnid dynasty (868–905)
Aḥmad’s first step upon his arrival in Egypt was to eliminate possible rivals. From an early date the administration of Egypt had been divided between the amīr (military governor), appointed by the caliph, and the ʿāmil (fiscal officer), who was sometimes appointed by the caliph, sometimes by the governor. When Aḥmad entered Egypt in 868 he found the office of ʿāmil filled by one Ibn al-Mudabbir, who over a period of years had gained control of Egyptian finances, enriching himself in the process, and was therefore reluctant to acknowledge Aḥmad’s authority. A struggle for power soon broke out between the two, which ended four years later with the transfer of Ibn al-Mudabbir to Syria and the assumption of his duties and powers by Aḥmad. An even more important step for Aḥmad was the acquisition of an army that would be independent of the caliphate and loyal to him. To build such an army, Aḥmad resorted to the same method the caliphs themselves used—the purchase of Mamluks who could be trained as military units loyal to their owner.
In 877, when Aḥmad failed to pay Egypt’s full contribution to the Abbasid campaign during the Zanj rebellion in Iraq, the caliphal government, dominated by the caliph’s brother al-Muwaffaq, realized that Egypt was slipping from imperial control. An expedition dispatched by al-Muwaffaq to remove Aḥmad from the governorship failed. Taking advantage of the caliphate’s preoccupation with the revolt, Aḥmad in 878 invaded Palestine and Syria, where he occupied the principal cities and garrisoned them with his troops. Thereafter he signified his autonomy by imprinting his name on the coinage along with that of the caliph. Although the regent al-Muwaffaq lacked the resources to engage Aḥmad in battle, he did have him publicly cursed in the mosques of the empire as a means of retaliation.
Internally, Aḥmad took active measures to raise Egyptian agricultural productivity and thereby to increase tax revenues; the huge surplus he left in the state treasury at his death in 884 is a measure of his success. Another tangible indication of his achievement for Egypt is the enormous mosque, the Mosque of Ahmad ibn Tulun, which he erected in a suburb of Al-Fusṭāṭ that is now Cairo; in contrast, no building comparable in grandeur had even been contemplated by the governors who preceded him.
The great benefits Aḥmad had gained for Egypt by keeping its resources within the country were squandered by his son and successor, Khumārawayh. He expended huge sums on luxurious appointments for his residence and paid a fortune as a dowry for a daughter he married to the caliph al-Muʿtaḍid (reigned 892–902) in 895. Nevertheless, Khumārawayh was able to maintain the Egyptian armies in the field, and he led them to victory both in Syria and in Mesopotamia. He resolved his father’s conflict with the caliphate by a combination of arms and diplomacy, so that Khumārawayh’s authority over Egypt, Syria, and Mesopotamia was given official caliphal recognition. This apparent strength evaporated when Khumārawayh was murdered in 896, leaving no funds with which his 14-year-old heir could pay the troops. The entire country fell into anarchy, which lasted until 905 when a caliphal army invaded Egypt and momentarily restored it to the status of a province ruled by governors sent from Baghdad.
The Ikhshīdid dynasty (935–969)
For 30 years the governors were unable to restore stability in Egypt. During this time, Egypt was subjected to attacks from the Shiʿi Fāṭimid dynasty based in North Africa and to the rampages of an unruly domestic army. The appointment of Muḥammad ibn Ṭughj, from Sogdiana in Central Asia, as governor in 935 led to a repetition of Aḥmad’s achievement; by bold measures Muḥammad established his authority over the treasury and the army, reasserted Egyptian influence in Syria, thwarted the Fāṭimids, and won the governorship of the holy cities of Arabia (Mecca and Medina). In addition, he founded a dynasty; his sons inherited his Sogdian princely title of ikhshīd, but their authority was usurped by their Abyssinian (Ethiopian) slave tutor, Abū al-Misk Kāfūr, who eventually ruled Egypt with the caliph’s sanction. When Kāfūr died in 968 the Ikhshīdids were unable to maintain order in the army and the bureaucracy. In the following year the Fāṭimids took advantage of the disorder in Egypt to launch yet another attack, this one so successful that it led to the occupation of the country by a Berber army led by the Fāṭimid general Jawhar.