Since the 1820s the Sudan had been ruled from Cairo by the dynasty of Muhammad Ali. Sudanese knew the regime as the Turkiyya and resented its heavy taxes, its corrupt officials and, in the 1870s, its use of European Christians such as Charles Gordon to suppress the slave trade on which many northern merchants depended. In 1881 a boatbuilder's son and Sufi ascetic, Muhammad Ahmad, announced that he was the Mahdi, the divinely guided figure expected to restore justice before the end of time. He called for a purified Islam and holy war against the "Turks."
Poorly led Egyptian columns sent against him were destroyed, the largest, under the British officer William Hicks, in 1883. Britain, which had just begun its occupation of Egypt, decided to evacuate the Sudan and sent Gordon to Khartoum to oversee the withdrawal. He stayed instead; the Mahdi's army stormed the city in January 1885 and killed him, two days before a relief force arrived. The Mahdi died months later, and his successor, the Khalifa Abdallahi, ruled a theocratic state from Omdurman for thirteen years, fighting Ethiopia, Egypt and internal rivals.
In the 1890s the Scramble for Africa brought the British back, anxious to keep France and others away from the upper Nile. Herbert Kitchener advanced methodically, building a railway as he went. At Omdurman on 2 September 1898 his troops, armed with Maxim guns, magazine rifles and artillery, killed some 10,000–12,000 Mahdist soldiers for the loss of about 48 of their own. The Khalifa was hunted down in 1899 and the Sudan became an Anglo-Egyptian condominium, in practice a British colony.
The CED lists the Mahdist wars among rebellions shaped by religious ideas (Topic 6.3: Indigenous Responses to State Expansion from 1750 to 1900). They resemble the Ghost Dance and the Xhosa cattle killing in their millenarian hope, but differ in having actually built a state — closer in that respect to the Sokoto Caliphate or the Taiping Heavenly Kingdom.