South Sudan, the world's youngest country, has been mired in a devastating civil war for more than four years, with tens of thousands of people killed, nearly four million displaced and its economy in ruins.
War broke out when President Salva Kiir accused his former deputy Riek Machar of plotting a coup just two years after the country gained independence from Sudan in 2011.
The arch-foes signed a "preliminary" power-sharing deal on Thursday, with a confirmation to follow on July 26. Here is some background:
World's youngest state
Before independence, the south of Sudan was ravaged by two civil wars (1956-1972 and 1983-2005) that pitted mainly Christian and animist insurgents in the south against Khartoum's Arab-dominated government.
Millions died in the conflicts.
A peace accord signed in 2005 by the government and southern rebels exempted the south from Islamic Sharia law and granted it six years of self-rule ahead of a referendum on independence.
The 2011 referendum went nearly 99 percent in favour of secession from the north and on July 9 that year, South Sudan proclaimed its independence. Kiir was sworn in as the country's first president with Machar as his deputy.
The international community — led by the US, China, Russia and the European Union, as well as Sudan — quickly recognised the new African state.
Former allies turn enemies
Kiir and Machar were on the same side in the push for independence from Khartoum, but ethnic and political rivalries drove them apart.
Tensions spiked when Machar — from the country's second-largest ethnic group, the Nuer — was fired as vice president in 2013.
His sacking came after Kiir, from the majority Dinka people, accused him of mounting a failed coup. Machar rejected the charge, in turn accusing the president of purging political rivals.
Civil war erupts
By December 2013 the new country had descended into civil war and the conflict, which spread to several states, saw ethnic massacres, attacks on civilians, widespread rape, the recruitment of child soldiers and other forms of brutality.
Under a 2015 peace deal, Machar was reinstalled as vice president and returned to the capital Juba, but fighting broke out there the next year and Machar and his forces fled.
Power-sharing and 'war crimes'
The two foes met for the first time in two years on June 20, 2018, in Addis Ababa. A week later in Khartoum they agreed on a "permanent" ceasefire.
South Sudan's government and rebels on July 6 settled to withdraw troops from urban areas as part of the agreement.
The following day in Kampala they accepted a power-sharing deal that would see Machar reinstated as vice president.
The UN on July 10 slammed "revolting acts" by South Sudan government-backed forces, describing "what appear to be deliberate, ruthless and brutally violent attacks on civilians, particularly against women and children".
Three days later the UN Security Council imposed an arms embargo on South Sudan and sanctions on two military officials.
Following more than four years of civil war, the Juba government coffers were empty and hyperinflation — which peaked at around 500 percent in 2016, decelerating to 155 percent in 2017 — had sent prices soaring. The South Sudanese pound collapsed.
Oil production — from which South Sudan gained 98 percent of its revenues on its independence — plummeted to about 120,000 barrels a day from a peak of 350,000, according to the World Bank.
Juba, which inherited three-quarters of the former Sudan's oil reserves during independence, depends on its northern neighbour's oil infrastructure — refineries and pipelines — for its exports.
The conflict has also heavily disrupted agriculture, sparking a major food crisis. In 2017 South Sudan endured four months of famine, which affected around 100,000 people.
Seven million South Sudanese, more than half of the population, will need food aid this year, according to the UN.