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.
"These two agreements are the ingredients to create an environment for achieving a total peace in my country," said Taban Deng, head of the rebel delegation, AFP reports.
However, the South Sudanese government has expressed scepticism over whether the opposition will be able to control all the militias involved in fighting, the BBC's Anne Soy reports.
Effective monitoring of the truce will be vital once it begins, as tension between the two sides is very high, South Sudan analyst James Copnall says.
The talks have now been adjourned and are due to continue on 7 February.
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.
The South Sudanese government had earlier said on its Twitter feed that it envisaged an amnesty for the detainees but only after their cases had been heard in court.
Another key rebel demand was for Ugandan troops fighting alongside the government forces to be withdrawn.
The question of Uganda's role was not raised during the signing ceremony but members of the rebel delegation said that they would bring up the issue again during the second round of talks, journalist Matthew Newsome told the BBC from Addis Ababa.
The US welcomed the deal, calling it a "critical first step" and urged both sides to "fully and swiftly implement the agreement".
UK Foreign Secretary William Hague also welcomed the ceasefire and called for an "inclusive process of national reconciliation".
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.