These attacks of the Shiʿites revealed another weakness in Egypt. There was strong reason to suspect that they had many sympathisers there. There was an active branch of the Ismaʿilian propaganda at work in the country, and all who were initiated in the sect were of necessity spies and helpers of the invaders. Two at least of the leading officials, the Qadi and the Treasurer were in correspondence with the Mahdi and in his employ: this does not mean that they were converts to the Shiʿite sect, but simply that they were disloyal to their own service as the result of personal jealousies and rivalries, the perennial bane of all oriental governments. It was only the support of the army which maintained Tekin, and even so he was not in a position to attack his rivals in the government. When he had been successful in clearing the country of the Mahdi’s forces, he had his reward in dismissal from the governorship in which he was succeeded by Muhammad b. Hamal, but three days later he was restored, to be deposed again soon afterwards as the result of more palace intrigues. The two following governors, Hilal b. Badr and Ahmad b. Kayghalagh, held office, the first for two years, the other for one, and then in 312 Takin was restored and remained governor until his death in 321. Conditions indeed were such that only a military leader with the support of the army could exercise any effective control in the country. The reinforcements sent from Baghdad in 302 had done more harm than the Shiʿite invaders; they had totally demoralised the native soldiery, and the army was now no more than a large troop of brigands who lived on the plunder of the country. At his appointment in 312 Takin established the army in camps around his own palace as well as in quarters in the building itself, and, more by the force of his own personality than anything else, managed to keep them fairly in hand until his death. It was no small feat, for he was utterly unable to provide them with their pay, which was many years in arrear. At his death the governorship was assumed by his son Muhammad, but he had not his father’s power or popularity, and was soon mobbed and driven out by the discontented soldiers clamouring for their pay. The Treasurer Madaraʿi, who was in the Mahdi’s employ and largely responsible for the disorder in the finances, was obliged to hide himself. Several ambitious officers assumed the title of Governor and tried the expedient of raising funds by brigandage organised on a larger scale than usual, and the country had relief only in the fact that these were soon occupied in war against one another. It is not difficult to understand that the eyes of many Egyptians were turned longingly towards Kairawan, where the Mahdi, in an efficient though somewhat brutal manner, was administering a firm and well ordered state, maintaining civil law and peace. This is the easier to appreciate when we remember that Ismaʿilian missionaries were busy in Egypt, and the orderly government at Kairawan would naturally form one of their arguments.

At this juncture, when Egypt was plunged in anarchy, the Khalif at Baghdad intervened and appointed as governor Muhammad b. Tughj the Ikhshid, son of the Emir of Syria, who had himself been governor of Damascus since 318. As his name denotes, this new governor was of Turkish birth. For some time now the Khalifs, seriously alarmed at the growing independence of the various dynasties of hereditary governors, especially in Persia and the neighbouring lands, had been introducing Turkish mercenaries, reckless of the inevitable consequences.

The conditions of the Khalifate at this time show a close parallel with those prevailing in Europe under the later Karlings, when “the governor,—count, abbot, or bishop—tightened his grasp, turned a delegated into an independent, a personal into a territorial authority, and hardly owned a distant and feeble suzerain” (Bryce: Holy Rom. Empire, p. 79). So each governor appointed by the Khalif became the founder of an independent dynasty, barely conceding the mention of the suzerain’s name in the khutba and on the coinage. Such were the Tahirids who ruled in Khurasan from 205 to 259, the Saffarids in Persia from 254 to 290, the Samanids in Transoxiana and Persia from 288 to about 400, the Hamdanids who established themselves at Mosul in 292, at Aleppo in 333, and ruled there until 394, and the Aghlabids whom we have seen in Kairawan.

The Ikhshids claimed to be descended from the ancient kings of Ferghana on the Jaxartes, a district inhabited by fighting races, from whom the Khalif al-Muʿtasim (218-227) drew many mercenaries. The first of the Ikhshids to serve the Khalifs was a mercenary named Juff, and he continued in the Khalif’s employ until his death in 247. One of his sons named Tughj was in the service of Luʿluʿ, who acted as squire to Ibn Tulun in Egypt, and, when his master died, in that of Ishaq b. Kundaj, and afterwards in that of Ibn Tulun’s son, Abu l-Jaysh Khumasawaih, who regarded him with great favour and formed a very high opinion of his military abilities, in consequence of which he procured for him the governorship of Damascus and Tiberias. At his patron’s death Tughj offered himself to the Khalif al-Muktafi, who considered this an act of marked loyalty, and was greatly pleased with him, and made him one of his confidential officers. These favours provoked the jealousy of the wazir al-ʿAbbas, and he succeeded in getting Tughj cast into prison where he died. He left two sons, Muhammad and ʿAbdullah, who burned to avenge their father’s death, and their resentment was gratified when they saw al-ʿAbbas executed by the Hamdanid al-Husayn.

After this the elder son, Muhammad, went to Syria and joined himself to Takin, who was governor of Syria as well as of Egypt. In this service he prospered and was made governor of Amman. Then in 316 he was appointed to Ramla, in 318 he was transferred to Damascus, which led the way to his appointment as Emir of Egypt. This last charge was given him in 321, but the state of Syria did not allow his immediate departure, and Egypt was left for a while in the hands of Ahmad b. Kayghalagh, who returned to office temporarily. By 324 Syria had been reduced to order, and Muhammad the Ikhshid went over to Egypt to assume his governorship in person, leaving his brother ʿAbdullah in Syria.

There were some in Egypt who did not like the prospect of this new governor, and amongst these was the Treasurer Madaraʿi, who induced the acting governor, Ibn Kayghalagh, to take up arms to resist his entry. The Egyptian army marched to the frontier and engaged the Syrians and Turks under the Ikhshid at Farama, the ancient Pelusiun, now more generally known as Tineh (Arabic tîn = Greek πηλός “mud”), near the Egyptian end of the “short desert route,” via al-Arish from Syria. The result was a complete defeat of the Egyptians, and so Muhammad the Ikhshid continued on his way to the capital Fustat (“Old Cairo”) without further opposition. Meanwhile the Syrian fleet had sailed up the Nile and anchored off Giza, thus commanding the city until the Ikhshid marched up his forces and took possession. The arrival of the new governor and his army, largely Turkish in composition, established a firm and efficient government in Egypt again until his death in 335. At their first arrival indeed the Turkish troops began plundering the city, but they were soon called to order and then, although the new governor was severe and exacted heavy contributions, this stern rule was welcomed as it recalled the peace and prosperity of the golden days of Ibn Tulun. The resultant peace very soon opened up the way to literary activity and scholarship, and Egypt began to follow, though at a distance, the culture of ʿIraq. This literary development, as well as theological discussion and debates on jurisprudence, centered in the “Old Mosque,” which was also the scene of the most important state functions.

Although the establishment of the Ikhshid rule in Egypt gives the appearance of supreme power to the Khalif at Baghdad, who seems thus able to dispose of provinces and appoint governors at discretion, his position at the time was really very precarious. The Buwayhid dynasty of governors had established itself in ʿIraq in 320 (= A.D. 932), but Baghdad itself remained under the Khalif until 334, though generally he was only a tool in the hands of the commander of the garrison. These Buwayhids claimed descent from Buwayh, a prince in the hill country of Daylam, and so ultimately from the ancient kings of Persia. They appeared as rivals of other Daylamites led by Bajukin, who was Emir al-Umara or “Supreme Prince,” and had control of the government under the Khalifs ar-Razi and al-Muttaqi. Alarmed at the progress of the Buwayhids, Bajukin took up arms against them in 327, but was compelled to abandon his efforts by the report of disorders in Baghdad. Soon afterwards Bajukin was killed by a band of Kurdish marauders, and the capital was left in a state of anarchy. Then Baridi became Chief Emir, but was expelled a few weeks later: then the Daylamite Kurtakin, who turned out to be a tyrant. At this the Khalif appealed to Ibn Raiq, the Emir of Syria, and he expelled Kurtakin. Not long afterwards Baridi attacked Baghdad and Ibn Raiq had to flee, taking the Khalif with him to Mosul, which was in the hands of the Hamdanids. As champions of the Khalifate the Hamdanids marched against Baghdad, took it, and ruled there for a short time, until the Turk Tuzun drove them out and made himself Emir al-Umara in 331. Then another revolt drove him out, and the Khalif appealed again to the Hamdanids and escaped to Mosul; but when peace was concluded between Tuzun and the Hamdanids the Khalif remained in their hands. At this time, indeed, the Khalifate was very far from showing the character of an absolute monarchy. All over the Muslim world the Sunni, or orthodox party, recognised the Khalif as the Commander of the Faithful, except of course in Spain where the Umayyads of Cordova assumed the title of Khalif in 317. Enjoying great dignity and prestige in an office which combined many of the characteristics of the Pope and Emperor in the West, he was in fact no more than a puppet, a valuable asset in the hands of any one of the warring dynasties of Asia, but possessing no real authority. Yet his formal recognition was eagerly sought as a precious endorsement of de facto rights by Muslim rulers, and even princes in far-off India humbly begged his approval of their titles. It seems indeed as though the office of Khalif gained in spiritual influence as it lost in political authority.

Whilst in exile and in Hamdanid’s hands, the Khalif appealed to the Ikhshid whom he had set over Egypt, and Muhammad visited him at Riqqa and invited him to take refuge in Egypt; but al-Muttaqi, though anxious for help to recover the external symbols of authority at Baghdad, was not willing to put himself so entirely in the Ikhshid’s hands; he knew that Ikhshid and Hamdanid alike only desired to possess his person as a kind of imperial regalia, and so he preferred to entrust himself to the Turk Tuzun, who at least could establish him in the capital. He reigned in Baghdad in name only until 333, when Tuzun deposed him, put out his eyes, and enthroned al-Mustakfi in his place. But this was followed by a period of anarchy in Baghdad, until in 334 the Buwayhid prince took the city. A few months later al-Mustakfi was deposed and replaced by al-Muʿti, whose position under the Buwayhid princes was parallel to that of the Frankish kings under the “Mayors of the Palace,” with the aggravated condition that the Khalifs were spiritual pontiffs and the Buwayhids were, like the Hamdanids, Shiʿite heretics of the “Twelvers” sect. Buwayhid’s rule over Baghdad lasted from 384 to 447, when the Emir was displaced by the Saljuk Turks under Tughril Beg. Throughout this period the Buwayhids were content with the title of Emir al-Umara; they never assumed that of Sultan.

It has been necessary for us to turn aside to note the position of the Khalifate at the time, for otherwise we should have some difficulty in understanding the course of events in Egypt, which now takes the foremost place in the policy of the African Shiʿites. It is often possible to ignore the contemporary history of Spain and of North Africa when following the course of events in Egypt, but Egypt forms so integral a part of the world of Islam that it is never possible to treat its history, even during the comparative isolation of the Fatimid period, without some passing note of the contemporary history of the Baghdad Khalifate.

Whilst these changes were taking place in Asia and the Ikhshid was consolidating his power in Egypt, the Mahdi continued ruling at Kairawan, and, though North Africa was one of the most turbulent and the least civilized parts of the Islamic world, his rule was stable and orderly. In 312 he added a suburb to the city which he called al-Muhammadiya, and which served as a kind of royal cantonments closed against the ordinary citizens, and used only as an official settlement of those engaged in the public administration and as the site of the various public offices. Such official suburbs were very frequent in oriental capitals, and become a regular feature of the great Muslim royal cities. The Mahdi’s later years were somewhat clouded by his relations with the Qarmatians, who were still active in Asia, and who caused the whole Ismaʿilian movement to be regarded with grave suspicion by the Muslim world at large.