South Sudan’s government and rebels have signed a ceasefire agreement after talks in Ethiopia.
Under the deal, signed in a hotel in the Ethiopian capital Addis Ababa, the fighting is due to come to an end within 24 hours.
In the past week, government forces have recaptured the two main cities under rebel control.
More than 500,000 people have been forced from their homes during the month-long conflict.
What started out as a political dispute between President Salva Kiir and his former deputy Riek Machar on 15 December escalated into full-scale conflict, with reports of ethnic killings.
A ceremony to mark the signing of the agreement on the “cessation of hostilities and the question of the detainees” took place at the hotel where the talks were hosted.
The agreement is thought to address the issue of 11 detainees whom the rebels wanted freed, and whose fate had previously left the talks deadlocked.
The detainees – allies of Mr Machar and prominent political figures from a faction of the governing SPLM party – were taken into custody when Mr Kiir first made the allegations of an attempted coup – which Mr Machar denies.
Another key rebel demand was for Ugandan troops fighting alongside the government forces to be withdrawn.
Last week, the UN human rights chief said both government soldiers and rebels had committed atrocities in South Sudan, one of the world’s poorest countries.
More than 70,000 civilians are seeking shelter at UN bases across South Sudan and the UN estimates that considerably more than 1,000 have been killed.
Following the outbreak of hostilities, it was agreed to boost the UN force and an extra 5,500 peacekeepers are being deployed to South Sudan, to bring its strength up to 12,500.