Modern Sudan is situated on the site of the ancient civilisation of Nubia, which predates Pharaonic Egypt. For centuries sovereignty was shuttled back and forth between the Egyptians, indigenous empires such as Kush, and a succession of independent Christian kingdoms.
After the 14th century AD the Mamelukes (Turkish rulers in Egypt) breached the formidable Nubian defences and established the dominance of Islam. By the 16th century the kingdom of Funj had become a powerful Muslim state and Sennar, 200km south of present-day Khartoum, was one of the great cultural centres of the Islamic world.
In 1821 the viceroy of Egypt, Mohammed Ali, conquered northern Sudan and opened the south to trade, with catastrophic results. Within a few decades British interests were also directed towards Sudan, aiming to control the Nile, contain French expansion from the west and draw the south into a British-East African federation. The European intrusion, and in particular the Christian missionary zeal that accompanied it, was resented by many Muslim Sudanese.
The revolution came in 1881, when one Mohammed Ahmed proclaimed himself to be the Mahdi – the person who, according to Muslim tradition, would rid the world of evil. Four years later he rid Khartoum of General Gordon, the British-appointed governor, and the Mahdists ruled Sudan until 1898, when they were defeated outside Omdurman by Lord Kitchener and his Anglo-Egyptian army. The British then imposed the Condominium Agreement, effectively making Sudan a British colony.
Sudan achieved independence in 1956, but in a forerunner of things to come, General Ibrahim Abboud summarily dismissed the winners of the first post-independence elections. Ever since, flirtations with democracy and military coups have been regular features of the Sudanese political landscape. So has war in the mostly non-Muslim south, which revolted after its demands for autonomy were rejected.
In 1969 Colonel Jaafar Nimeiri assumed power and held it for 16 years, surviving several coup attempts, and making numerous twists and turns in policy to outflank opponents and keep aid donors happy. Most importantly, by signing the 1972 Addis Ababa Agreement to grant the southern provinces a measure of autonomy he quelled the civil war for more than a decade.
In 1983 Nimeiri scrapped the autonomy accord and imposed sharia (Islamic law) over the whole country. Exactly what he hoped to achieve by this is unclear, but the effect on the southern population was entirely predictable, and hostilities recommenced almost immediately. Army commander John Garang deserted to form the Sudanese People’s Liberation Army (SPLA), which quickly took control of much of the south.
Nimeiri was deposed in 1985 and replaced first by a Transitional Military Council, then, after elections the next year, Sadiq al-Mahdi became prime minister. In July 1989 power was seized by the current president, Lieutenant General Omar Hassan Ahmad al-Bashir; however, Hassan al-Turabi, fundamentalist leader of the National Islamic Front (NIF), was widely seen as the man with real power.
The government’s brand of belligerent fundamentalism, border disputes with half its neighbours and possible complicity in a 1995 assassination attempt on Egypt’s president soon cost Sudan all its regional friends.
The year 1999 was something of a watershed in Sudanese politics: in December, just when the country’s domestic and international situation seemed to be improving, President al-Bashir dissolved parliament, suspended the constitution and imposed a three-month state of emergency; all as part of an internal power struggle with Al-Turabi. The subsequent elections in December 2000 were boycotted by opposition parties, giving al-Bashir an easy win, and in 2001 Al-Turabi and several members of his party were arrested after signing an agreement with the SPLA.
By 2002 things were looking up again – the economy had stabilised and a ceasefire was called after President al-Bashir and SPLA leader John Garang met in Nairobi – but it seems good news in Sudan is always followed by bad. In February 2003 black African rebels in the western Darfur region rose up against the government they accused of oppression and neglect. The army’s heavy-handed response, assisted by pro-government Arab militias (the Janjaweed), escalated to what many have called genocide. The government’s scorched-earth campaign killed some 200,000 Sudanese and uprooted millions more.
While Darfur spun out of control, peace crept forward in the south, and in January 2005 a deal was signed ending Africa’s longest civil war. It included accords on sharing power and wealth (including equal distribution of oil export revenue), and six years of southern autonomy followed by a referendum on independence. In July the beloved Garang became the first vice president in a power-sharing government, and president of the south, but was killed less than a month later in a helicopter crash. Garang’s No.2, Salva Kiir, took his place and has earned praise.
By the middle of 2006 Sudan was at a crossroads. While a Darfuri peace accord with some rebel factions was signed in May, the killing got worse and al-Bashir, fearing they would arrest people on war-crimes charges, refused to allow UN peacekeepers to replace the small and ineffective African Union force. Meanwhile foot-dragging on the implementation of key elements of the peace agreement threatened to derail the peace in the south.
However, in January 2011, the cornerstone of the 2005 peace deal was finally enacted - southerners voted in a referendum on whether to remain part of a united Sudan or opt for independence from Khartoum. They voted overwhelmingly for independence from north Sudan. On 9 July 2011, Sudan divided in two, giving birth to the world's newest nation: South Sudan. Even discounting the 40 years of war with its estimated combined total of 2.4 million deaths, the build-up to South Sudan's secession has not been easy and the path ahead is likely to be turbulent. For the latest news on Sudan, check out the BBC's news updates.