Muhammad Ahmad was born in 1844 in Dirar Island off Dongola, a member of an 'Arabized Nubian' family from Dongola. They moved to Khartoum for better prospects for his family, and all of Muhammad's brothers entered the boatbuilding business, following their father. Muhammad instead focussed on religious studies like his great-grandfather, a respected shariff.
He learned the Koran in Khartoum and Kararie, and later he studied fiqh under Sheikh Muhammad Kheir, interested mostly in the Sufi teachings. In 1861 he approached Sheikh Muhammad ash Sharif, the leader of Sammaniyya Sect, to join his students and learn more on Sufism. When sheikh Muhammad realized Muhammad's dedication he appointed him shaykh, and permitted him to give Tariqa and Uhuud to new followers.
In 1871 his family moved again to Aba Island in western Sudan where he built a mosque and started to teach the Koran. He soon gained a notable reputation among the local population as an excellent speaker and mystic. The broad thrust of his teaching followed that of other reformers, his Islam was one devoted to the words of the Prophet and based on a return to the virtues of prayer and simplicity as laid down in the Koran. Any deviation from the Koran was therefore heresy.
Over the next ten years he travelled widely, to Dongola, Kordofan and Sinnar. During his travels he was struck by the hatred for the Ottoman-Egyptian rulers, and found that as soon as anyone educated and well-spoken appeared, the local populations would declare him Mahdi and hope for his deliverance. He was joined on his travels by Abdallahi ibn Muhammad, a Baqqara from southern Darfur, who's organizational capabilities proved invaluable. On his return to Aba Island in 1881, Muhammad Ahmad proclaimed himself Al Mahdi al Muntazar and started to raise an army.
Even after the Mahdi proclaimed a jihad, or holy war, against the Turkiyah, he was dismissed a religious fanatic. The government paid more attention when his religious zeal turned to denunciation of tax collectors. To avoid arrest, the Mahdi and a party of his followers, the Ansar (known in the west inaccurately as the Dervishes), made a long march to Kurdufan. There he gained a large number of recruits, especially from the Baqqara. There he wrote to many Sudanese tribal leaders and gained their support, or at least neutrality, and he was also supported by the slave traders who were looking to return to power. They were also joined by the Hadendowa Beja, who were rallied to the Mahdi by an Ansar captain, Usman Digna.
Early in 1882, the Ansar, armed with spears and swords, overwhelmed a 7,000-man Egyptian force not far from Al Ubayyid and seized their rifles and ammunition. The Mahdi followed up this victory by laying siege to Al Ubayyid and starving it into submission after four months. The Ansar, now 30,000 strong, then defeated an 8,000-man Egyptian relief force at Sheikan. Next the Mahdi captured Darfur, while at the same time another rebellion by the Beja (the fuzzy-wuzzies) in the east started.
An understanding of the British role in these events is important. In 1869 the Suez Canal opened, and to defend the waterway Britain sought a greater role in Egyptian affairs. In 1873 the British government supported a program where an Anglo-French debt commission assumed responsibility for managing Egypt's fiscal affairs. This commission eventually forced Khedive Ismail to abdicate in favor of his son Tawfiq in 1877, leading to a period of political turmoil.
Ismail had appointed Charles George Gordon to the post of governor general of Sudan. Soon after he arrived he ended the slave trade there, before his arrival some 7 out of 8 negros in the Sudan were enslaved by the tiny minority of Arabs. Upon Ismail's abdication Gordon found himself with dramatically decreased support, and he eventually resigned his post in 1880, exhausted by years of work. His policies were soon adbandoned by the new governors. By September 1882 the situation in the Sudan was poor, and given their lack of interest in the area the British decided to adbandon it in December 1883, ordering Gordon to return to Khartoum and organize a withdrawl.
Gordon reached Khartoum in February 1884. He found that the routes northward were too dangerous to extricate the garrisons, and so pressed for reinforcements to be sent from Cairo to help with the withdrawl. He also suggested that his old enemy Zubayr, a fine military commander, be given tacit control of the Sudan in order to provide a counter to the Ansar. London rejected both proposals, and so Gordon prepared for a fight.
In March 1884 Gordon tried a small offensive to clear the road northward to Egypt, but a number of the officers in the Egyptian force went over to the enemy and their forces fled the field after firing a single salvo. This convinced him that he could carry out only defensive operations, and he returned to Khartoum to construct defensive works. By April 1884 Gordon had managed to evacuate some 2,500 of the foreign population that were able to make the trek northwards. His mobile force under Colonel Stewart then returned to the city as well, after repeated incidents where the 200 or so Egyptian forces under his command would turn and run at the slightest provocation.
That month the rebellion had reached Khartoum, and Gordon was completely cut off. Nevertheless his defensive works, consisting mainly of mines, proved so frightening to the Ansar that they were unable to penetrate into the city. Stewart maintained a number of small skirmishes using gunboats on the Nile once the waters rose, and in August managed to recapture Berber for a short time. However Stewart was killed soon after in another foray from Berber to Dongola.
Under increasing pressure from the public to support him, the British sent a "flying column" overland to Khartoum while four gunboats navigated the Nile. The camel forces under Lord Garnet Joseph Wolseley were stopped at Abu Tulayh by the Beja, and the boats arrived on January 28, 1885, to find the town had fallen two days earlier. The Ansar had waited for the Nile spring flood to recede before attacking the poorly defended river approach, overcoming the garrison. Gordon was killed, apparently with a revolver in each hand firing until he ran out of ammunition, and his head was delivered to the Mahdi's tent. Kassala and Sannar fell soon after, and by the end of 1885 the Ansar had begun to move into the southern region. In all Sudan, only Sawakin, reinforced by Indian army troops, and Wadi Halfa on the northern frontier remained in Anglo-Egyptian hands.
With Sudan now in Sudanese hands, the Mahdi formed a government. The Mahdiyah (Mahdist regime) imposed traditional Islamic laws, and run like a military camp. Sharia courts enforced Islamic law and the Mahdi's own commands. He also authorized the burning of lists of pedigrees and books of law and theology because of their association with the old regime, and because he believed that they accentuated tribalism at the expense of religious unity. The Mahdi modified Islam's five pillars to support the dogma that loyalty to him was essential to true belief. The Mahdi also added the declaration and Muhammad Ahmad is the Mahdi of God and the representative of His Prophet to the recitation of the shahada. Moreover, service in the jihad replaced the hajj, pilgrimage to Mecca, as a duty incumbent on the faithful. Zakat (almsgiving) became the tax paid to the state. The Mahdi justified these reforms as responses to instructions conveyed to him by God in visions.
Six months after the capture of Khartoum, Muhammad Ahmad died of typhus. The Mahdi had planned for this eventuality and chosen three deputies to replace him, in emulation of the Prophet Muhammad. This led to a long period of disarray, due to rivalry among the three, each supported by people of his native region. This continued until 1891, when Abdallahi ibn Muhammad, with the help primarily of the Baqqara Arabs, emerged as unchallenged leader. Abdallahi, referred to as the Khalifa (successor), purged the Mahdiyah of members of the Mahdi's family and many of his early religious disciples.
The Khalifa was committed to the Mahdi's vision of extending the Mahdiyah through jihad, which led to strained relations with practically everyone else. For example, the Khalifa rejected an offer of an alliance against the Europeans by Ethiopia's negus (king), Yohannes IV. In 1887 a 60,000-man Ansar army invaded Ethiopia, penetrated as far as Gonder, and captured prisoners and booty. The Khalifa then refused to conclude peace with Ethiopia. In March 1889, an Ethiopian force, commanded by the king, marched on Qallabat; however, after Yohannes IV fell in battle, the Ethiopians withdrew. Abd ar Rahman an Nujumi, the Khalifa's best general, invaded Egypt in 1889, but British-led Egyptian troops defeated the Ansar at Tushkah. This was the first lost battle by the Mahdiyah. Further attacks into Equatoria were stopped by the Belgians, and in 1893 the Italians repulsed an Ansar attack at Akordat (in Eritrea) and forced the Ansar to withdraw from Ethiopia.
By this point British interest in the area was once again growing, due to the interest of the French and Belgians in nearby areas. As each of these forces moved up the Nile, the British felt they required a presense in the Sudan in order to validate their claims to it via Egypt's annexation. In 1892 Herbert Kitchener had been promoted to the post of commander in Egypt, and in 1895 they started plans for the re-conquest of the Sudan.
Kitchener's forces, Anglo-Egyptian Nile Expeditionary Force, the consisted of 25,800 men, including 8,600 British regulars, and a flotilla of gunboats. They took and fortified Wadi Halfa in 1895, and started south at a very slow pace the next March. In September Kitchener captured Dunqulah, and constructed several rail lines to ensure supplies. There were small battles at Abu Hamad and Atbarah, both times the Ansar were defeated by the massive English firepower which now included Maxim machine guns. Kitchener then marched on Omdurman.
On September 2, 1898, the Battle of Omdurman opened with a frontal assault by the Mahdiyah's 52,000-man army. Over the next five hours some 11,000 of their forces would be killed, against about 40 of the Anglo-Egyptian forces (and about 400 wounded). The Mahdiyah ended at this point and the British once again took control of the Sudan. The Khalifa escaped and reformed an army, but this was defeated in 1899 at the Battle of Umm Diwaykarat and the Khalifa was killed.
During their short reign, the Mahdiyah had destroyed the Sudanese economy, and about half of the population died due to famine, disease, persecution, and warfare. Their efforts to wipe out the former tribal differences left few loyalties intact, and intercene warfare was common. In general the country welcomed the fall of the Mahdiyah.