Ahmed was born in Dongola and joined the Egyptian civil service. Later, he became a slave trader and finally led a relentless and successful uprising against Egyptian rule in eastern Sudan. After defeating Hicks Pasha and an Egyptian army in 1883, he established a theocratic state and made El Obeid his capital. In 1885, he besieged the town of Khartoum which was held by the British. The commanding officer of the British garrison General Gordon was killed just two days before a relief force arrived. The Mahdi eventually died at the battle of Omdurman when Field-Marshall Kitchener retook Sudan with a combined British and Egyptian force.