In 1820, the Egyptian wāli Muhammad Ali Pasha invaded and conquered northern Sudan. The region had longstanding linguistic, cultural, religious, and economic ties to Egypt and had been partially under the same government at intermittent periods since the times of the pharoahs. Muhammad Ali was aggressively pursuing a policy of expanding his power with a view to possibly supplanting the Ottoman Empire (to which he technically owed fealty) and saw Sudan as a valuable addition to his Egyptian dominions. During his reign and that of his successors, Egypt and Sudan came to be administered as one political entity, with all ruling members of the Muhammad Ali Dynasty seeking to preserve and extend the "unity of the Nile Valley". This policy was expanded and intensified most notably by Muhammad Ali's grandson, Ismail Pasha, under whose reign most of the remainder of modern-day Sudan was conquered.
Abdalla's religious government imposed traditional Islamic laws upon Sudan and stressed the need to continue the armed struggle until the British had been completely expelled from the country and all of Egypt and Sudan was under his Mahdiya. Though he died six months after the fall of Khartoum, Abdalla's call was fully echoed by his successor, Abdallahi ibn Muhammad who invaded Ethiopia in 1887, penetrating as far as Gondar, and the remainder of northern Sudan and Egypt in 1889. This invasion was halted by Tewfik's forces, and was followed four later by withdrawal from Ethiopia.
After a series of Mahdist defeats, Tewfik's son and successor, Abbas II, and the British decided to re-establish control over Sudan. Leading a joint Egyptian-British force, Lord Kitchener led military campaigns from 1896 to 1898. Kitchener's campaigns culminated in the Battle of Omdurman. Exercising the leverage which their military superiority provided, the British forced Abbas to accept British control in Sudan. Whereas British influence in Egypt was officially advisory (though in reality it was far more direct), the British insisted that their role in Sudan be formalized. Thus, an agreement was reached in 1899 establishing Anglo-Egyptian rule, under which Sudan was to be administered by a governor-general appointed by Egypt with British consent. In reality, much to the revulsion of Egyptian and Sudanese nationalists, Sudan was effectively administered as a British imperial possession. Pursuing a policy of divide and rule, the British were keen to reverse the process, started under Muhammad Ali, of uniting the Nile Valley under Egyptian leadership, and sought to frustrate all efforts aimed at further uniting the two countries.
This policy was internalized within Sudan itself, with the British determined to exacerbate differences and frictions between Sudan's numerous different ethnic groups. From 1924 onwards, the British essentially divided Sudan into two separate territories - a predominantly Muslim Arabic-speaking north, and a predominantly Animist and Christian south, where the use of English was encouraged.
The continued British occupation of Sudan fueled an increasingly strident nationalist backlash in Egypt, with Egyptian nationalist leaders determined to force Britain to recognise a single independent union of Egypt and Sudan. With the formal end of Ottoman rule in 1914, Husayn Kamil was declared Sultan of Egypt and Sudan, as was his brother Fuad I who succeeded him. The insistence of a single Egyptian-Sudanese state persisted when the Sultanate was re-titled the Kingdom of Egypt and Sudan, but the British continued to frustrate these efforts.
The failure of the government in Cairo to end the British occupation led to separate efforts for independence in Sudan itself, the first of which was led by a group of Sudanese military officers known as the White Flag League in 1924. The group was led by first lieutenant Ali Abdullatif and first lieutenant Abdul Fadil Almaz. The latter led an insurrection of the military training academy, which ended in their defeat and the death of Almaz after the British army blew up the military hospital where he was garrisoned. This defeat was (allegedly) partially the result of the Egyptian garrison in Khartoum North not supporting the insurrection with artillery as was previously promised.
Even when the British ended their occupation of Egypt in 1936 (with the exception of the Suez Canal Zone), they maintained their forces in Sudan. Successive governments in Cairo, repeatedly declaring their abrogation of the condominium agreement, declared the British presence in Sudan to be illegitimate, and insisted on full British recognition of King Farouk as King of Egypt and Sudan, a recognition which the British were loath to grant. It was the Egyptian Revolution of 1952 which finally set a series of events in motion which would eventually end the British occupation of Sudan. Having abolished the monarchy in 1953, Egypt's new leaders, Muhammad Naguib, whose mother was Sudanese, and Gamal Abdel Nasser, believed the only way to end British domination in Sudan was for Egypt itself to officially abandon its sovereignty over Sudan. Since Britain's own claim to control in Sudan theoretically depended upon Egyptian sovereignty, the revolutionaries calculated that this tactic would leave Britain with no option but to withdraw. Their calculation proved to be correct, and in 1954 the governments of Egypt and Britain signed a treaty guaranteeing Sudanese independence. On January 1 1956, the date agreed between the Egyptian and British governments, Sudan became an independent sovereign state, ending its nearly 136 year union with Egypt and 55 year rule by the British.