In 1821, the Albanian-Ottoman ruler of Egypt, Muhammad Ali, had invaded and conquered northern Sudan. Although technically the Wāli of Egypt under theOttoman Sultan, Muhammad Ali styled himself as Khedive of a virtually independent Egypt. Seeking to add Sudan to his domains, he sent his third son Ismail (not to be confused with Ismail the Magnificent mentioned later) to conquer the country, and subsequently incorporate it into Egypt. This policy was expanded and intensified by Ibrahim‘s son, Ismail I, under whose reign most of the remainder of modern-day Sudan was conquered. The Egyptian authorities made significant improvements to the Sudanese infrastructure (mainly in the north), especially with regard to irrigation and cotton production. In 1879, the Great Powers forced the removal of Ismail and established his son Tewfik I in his place. Tewfik’s corruption and mismanagement resulted in the Orabi Revolt, which threatened the Khedive’s survival. Tewfik appealed for help to the British, who subsequently occupied Egypt in 1882. Sudan was left in the hands of the Khedivial government, and the mismanagement and corruption of its officials. During the 1870s, European initiatives against the slave trade caused an economic crisis in northern Sudan, precipitating the rise of Mahdist forces.
Eventually, a revolt broke out in Sudan, led by Muhammad Ahmad ibn Abd Allah, the Mahdi (Guided One), who sought to end foreign presence in Sudan. Mahdi revolution succeed in January 1885. Later that year, the Mahdi’s forces attacked and entered Khartoum[clarification needed], which had been defended by the British Governor-General, Charles George Gordon (also known as Gordon of Khartoum), who was killed. Egypt and Britain subsequently withdrew forces from Sudan leaving the Mahdi and his successor to form a 14 year rule of Sudan.
Info from https://en.wikipedia.org/wiki/Sudan