The Mahdist War (; 1881–1899) was fought between the Mahdist Sudanese, led by Muhammad Ahmad bin Abdullah, who had proclaimed himself the "Mahdi" of Islam (the "Guided One"), and the forces of the Khedivate of Egypt, initially, and later the forces of Britain. After four years, the Mahdist rebels overthrew the Ottoman-Egyptian administration with the fall of Khartoum and gained control over Sudan. The Mahdist State launched several unsuccessful invasions of their neighbours, expanding the scale of the conflict to also include the Italian Empire, the Congo Free State and the Ethiopian Empire. They also faced significant internal rebellion, and a major famine.

Anglo-Egyptian forces reconquered Sudan in 1898 and the Mahdist state collapsed following defeat at the battle of Omdurman. The last organised resistance from the Mahdists ended the next year, leading to the creation of Anglo-Egyptian Sudan (1899–1956), a de jure condominium of the British Empire and the Kingdom of Egypt, in which Britain had de facto control over Sudan.

Background Following Muhammad Ali's invasion in 1820–1821, Sudan was incorporated into the Ottoman–Egyptian state and governed as part of the Turco-Egyptian administration, Turco-Egyptian Sudan, known locally as 'the Turkiyah'.Holt, P. M., and M. W. Daly, A History of the Sudan: From the Coming of Islam to the Present Day, 6th ed. (London: Longman, 2011), pp. 66–75.

Throughout the period of Turco-Egyptian rule, large sections of the Sudanese population suffered severe economic hardship as a result of heavy taxation, forced labor, and administrative coercion imposed by the central government. Taxes were levied on agriculture, livestock, and trade, and were often collected through local intermediaries and military detachments, frequently using violence and intimidation. In years of drought or famine, these burdens led to widespread displacement and social disruption.Hill, Richard, Egypt in the Sudan, 1820–1881 (Oxford: Oxford University Press, 1959), pp. 90–104.Warburg, Gabriel, “Some Social and Economic Aspects of Turko-Egyptian Rule in the Sudan,” Sudanic Africa 3 (1992): 1–23.

Many inhabitants of the Nile Valley migrated toward Kordofan and Darfur to escape taxation and conscription. There, they increasingly engaged in commerce and caravan trade. From this environment emerged the jallāba, a merchant class specializing in long-distance trade, credit, and brokerage between local producers and external markets. The term jallāba referred to an economic and social category rather than an ethnic group or tribe.Bjørkelo, Anders J., Prelude to the Mahdiyya: Peasants and Traders in the Shendi Region, 1821–1885 (Cambridge: Cambridge University Press, 1989), pp. 54–78.Holt and Daly, History of the Sudan, pp. 82–84.

A significant proportion of the jallāba were involved in the slave trade, which remained a major component of Sudan's economy during the Turco-Egyptian period. Slaves were exported north to Egypt and the Mediterranean world, as well as used internally for agriculture, military service, and domestic labor.Clarence-Smith, W. G., Islam and the Abolition of Slavery (Oxford: Oxford University Press, 2006), pp. 78–84.Hill, Egypt in the Sudan, pp. 123–134.

By the mid-19th century, Egypt was ruled by Isma'il Pasha of Egypt. His ambitious modernization projects, including the construction of the Suez Canal, plunged Egypt into massive foreign debt. In 1876, Britain and France imposed the Caisse de la Dette Publique, an international financial commission that took control of Egypt's revenues. This foreign intervention undermined Ismail's authority and led to his forced abdication in 1879 in favor of his son Tewfik Pasha.Cain, P. J., and A. G. Hopkins, British Imperialism, 1688–2000 (London: Longman, 2002), pp. 331–334.Landau, Jacob M., The Politics of Pan-Islam (Oxford: Clarendon Press, 1990), pp. 27–29.

In 1873, Ismail appointed General Charles George Gordon as Governor of the Equatorial Provinces of Sudan, later expanding his authority to include Darfur. Gordon attempted to suppress the slave trade and defeat the powerful trader-warlord al-Zubayr Rahma Mansur, whose commercial empire dominated much of western Sudan.Holt and Daly, History of the Sudan, pp. 96–99.Jeal, Tim, Gordon: A Personal History (London: Hodder & Stoughton, 1984), pp. 234–250.

After Ismail's abdication, Gordon's political support and financial resources collapsed. He resigned in 1880 and left Sudan in early 1881. His reforms were largely abandoned by subsequent administrators, and the resentment of merchants, tribal leaders, religious figures, and rural populations toward Turco-Egyptian rule continued to intensify.Hill, Egypt in the Sudan, pp. 148–152.Holt and Daly, History of the Sudan, pp. 101–103.

Although conditions in Sudan deteriorated rapidly, the British government refused to assume direct responsibility. Foreign Secretary Earl Granville declared that "Her Majesty's Government are in no way responsible for operations in the Sudan," reflecting Britain's desire to control Egypt without becoming militarily entangled in its African possessions.Gallagher, John, and Ronald Robinson, “The Imperialism of Free Trade,” Economic History Review 6, no. 1 (1953): 13–15.

History Mahdi uprising

Among the forces seen as the causes of the uprising were ethnic Sudanese anger at the foreign Egyptian rulers, Muslim revivalist anger at the Egyptian's lax religious standards and willingness to appoint non-Muslims such as the Christian Charles Gordon to high positions, and Sudanese Sufi resistance to "dry, scholastic Islam of Egyptian officialdom."Mortimer, Edward, Faith and Power, Vintage, 1982, p. 77. Another widely reported source of frustration was the Egyptian abolition of the slave trade, one of the main sources of income in Sudan at the time.

In the 1870s, a Muslim cleric named Muhammad Ahmad preached renewal of the faith and liberation of the land, and began attracting followers. Soon in open revolt against the Egyptians, Muhammad Ahmad proclaimed himself the Mahdi, the promised redeemer of the Islamic world. In August 1881 the then-governor of the Sudan, Rauf Pasha, sent two companies of infantry each with one machine gun to arrest him. The captains of the two companies were each promised promotion if their soldiers were the ones to return the Mahdi to the governor. Both companies disembarked from the steamer that had brought them up the Nile to Aba Island and approached the Mahdi's village from separate directions. Arriving simultaneously, each force began to fire blindly on the other, allowing the Mahdi's scant followers to attack and destroy each force in turn at the Battle of Aba.

The Mahdi then began a strategic retreat to Kordofan, where he was at a distance from the seat of government in Khartoum. This movement, posed as a triumphant progress, incited many of the Arab tribes to rise in support of the Jihad the Mahdi had declared against the Egyptian government.

The Mahdi and the forces of his Ansar arrived in the Nuba Mountains of south Kordofan around early November 1881. Another Egyptian expedition dispatched from Fashoda arrived around one month later; this force was ambushed and slaughtered on the night of 9 December 1881. Like the earlier Aba Island force, this force consisted of two 200 man strong Egyptian raised infantry companies, this time augmented with an additional 1,000 native irregulars, the force commander – Colonel Rashid Bay Ahman – and all his principal leadership team were killed. It is unknown if any of Colonel Ahman's troops survived.Snook, op.cit., p.13

As these military incursions were happening, the Mahdi legitimized his movement by drawing deliberate parallels to the life of Muhammad. He called his followers Ansar, after the people who greeted Muhammad in Medina, and he called his flight from the British, the hijrah, after Muhammad's flight from the Quraysh. The Mahdi also appointed commanders to represent three of the four Righteous Caliphs; for example, he announced that Abdullahi ibn Muhammad, his eventual successor, represented Abu Bakr Al Sidiq, Muhammad's successor.

The Egyptian administration in the Sudan, now thoroughly concerned by the scale of the uprising, assembled a force of 4,000 troops under Yusef Pasha. In mid-1882, this force approached the Mahdist gathering, whose members were poorly clothed, half starving, and armed only with sticks and stones. However, supreme overconfidence led the Egyptian army into camping within sight of the Mahdist 'army' without posting sentries. The Mahdi led a dawn assault on 7 June 1882, which slaughtered the entire army. The rebels gained vast stores of arms, ammunition, military clothing and other supplies.

Hicks expedition

With the Egyptian government now passing largely under British control, the European powers became increasingly aware of the troubles in Sudan. The British advisers to the Egyptian government gave tacit consent for another expedition. Throughout the summer of 1883, Egyptian troops were concentrated at Khartoum, eventually reaching the strength of around 7,300 infantry, 1,000 cavalry, and an artillery force of 300 personnel hauling between them 4 Krupp 80mm field guns, 10 brass mountain guns and 6 Nordenfelt guns.Snook, op. cit., p.25 This force was placed under the command of retired Bombay Army colonel William Hicks and twelve European officers. The force was, in the words of Winston Churchill, "perhaps the worst army that has ever marched to war". Unpaid, untrained, and undisciplined, its soldiers having more in common with their enemies than with their officers.

El-Obeid, the city whose siege Hicks had intended to relieve, had already fallen by the time the expedition left Khartoum, but Hicks continued anyway, although not confident of his chances of success. Upon his approach, the Mahdi assembled an army of about 40,000 men and drilled them rigorously in the art of war, equipping them with the arms and ammunition captured in previous battles. On 3 and 4 November 1883, when Hicks' forces offered battle, the Mahdist army was a credible military force, which defeated Hicks' army with only about 500 Egyptians surviving the Battle of El Obeid.

Egyptian evacuation At this time, the British Empire was increasingly entrenching itself in the workings of the Egyptian government. Egypt was struggling under a barely maintainable debt repayment structure for its enormous European debt. For the Egyptian government to avoid further interference from its European creditors, it had to ensure that the debt interest was paid on time, every time. To this end, the Egyptian treasury, initially crippled by corruption and bureaucracy, was placed by the British almost entirely under the control of a financial advisor, who exercised the power of veto over all matters of financial policy. The holders of this office, first Sir Auckland Colvin, and later Sir Edgar VincentMilner p. 86—were instructed to be as frugal possible in Egypt's financial affairs. Maintaining the garrisons in the Sudan was costing the Egyptian government over 100,000 Egyptian pounds a year, an unmaintainable expense.