Khartoum is young for a Nile city. The Egyptian army set up an outpost here in 1821, 24 km north of the ancient city of Soba, after Egypt's ruler Muhammad Ali brought Sudan under his rule. In 1823 the colonial government moved over from Wad Madani and the camp became a town. Caravans between Ethiopia and Egypt rested here, and it became a centre of the slave trade.
Water nearly ended it in 1854: heavy rains and floods destroyed most of the town, and it was rebuilt in mud and stone instead of thatch and straw. By then European consulates had opened here. Pressure from Europe closed the public slave market that same year, but people kept being sold and trafficked in large numbers. The explorer Samuel Baker wrote in 1862 that slavery was what kept the town going. In 2020 activists asked for a street named after the slave trader al-Zubayr to be renamed, since it leads to the base where the 2019 killings took place.
The siege began in March 1884, when followers of the Mahdi, Muhammad Ahmad, surrounded the Egyptian garrison under the British general Charles Gordon. Trenches and a wall between the two Niles did not hold. The Mahdists took the city on 26 January 1885 and killed the garrison. Survivors were deported to Omdurman, newly founded, and Khartoum was left largely destroyed and empty. Omdurman is where the Mahdi's tomb and the Khalifa's house stand today.
Anglo-Egyptian forces retook Sudan in 1898 and rebuilt Khartoum with streets laid out to echo the Union Jack. Bahri began as a garrison with a dockyard and a railhead, while Omdurman stayed the biggest part and kept its old shape. Under Reginald Wingate the Governor-General's Palace went up in red brick, and the town took on a Victorian look with Mediterranean windows and balconies. Gordon Memorial College opened in 1903 (it is now the University of Khartoum) and the railway to Port Sudan was finished in 1919. Walk Nile Street today and the colonial buildings are still there, shabby, and used as ministries, schools and a hotel.
Sudan became independent in 1956 with Khartoum as its capital, and people poured in from the countryside: 185,000 by 1964, 334,000 at the 1973 census. Refugees followed. Through the 1970s and 1980s hundreds of thousands came from Chad, Eritrea, Ethiopia and Uganda. Some blended into the city and others settled in large slums on its edge. Since the mid 1980s the war in the south and in Darfur has sent more. Greater Khartoum is estimated at 7.1 million people, the largest urban area in the country.
The 1990s were harsh. In November 1991 the government of Omar al-Bashir tried to clear half the city of residents it called squatters, mostly southerners it distrusted, and put about 425,000 of them in five desert camps an hour's drive away. In the same years Osama bin Laden lived in Khartoum until he was banished in 1996. After the 1998 embassy bombings the United States fired cruise missiles at the al-Shifa factory in Bahri, and its ruins can still be visited.
On 3 June 2019, Rapid Support Forces soldiers killed more than 100 people to break up protests demanding civilian government (the government's own figure was 61). A military coup in October 2021 left at least 7 dead. On 15 April 2023 fighting between the army and the RSF began across Sudan, including at the presidential palace, the RSF headquarters and the airport in Khartoum. The army regained full control of the city on 26 March 2025, leaving widespread destruction.