South Sudan's President Salva Kiir and his arch-foe Riek Machar agreed Wednesday to a "permanent" ceasefire to take effect within 72 hours, raising hopes of an end to four-and-a-half years of war.
The conflict erupted in 2013, around two years after South Sudan won independence from Sudan, when Kiir accused his then-deputy Machar of plotting a coup.
It claimed tens of thousands of lives, displaced four million people and left the newly created country's oil-rich economy in tatters.
"All parties have agreed on a permanent ceasefire within 72 hours," Sudan's Foreign Minister Al-Dierdiry Ahmed said after talks between the two leaders in the Sudanese capital.
Kiir and Machar then signed the document -- called the "Khartoum Declaration" -- in the presence of Sudanese President Omar al-Bashir.
"It is the day that our people of South Sudan have been expecting, and I'm happy that it has finally been achieved," Kiir said after inking the agreement.
Machar said the ceasefire, applicable across the entire country, must finally lead to the "ending of the war".
The latest push for peace in South Sudan comes as part of a fresh bid launched by East African leaders and with the two factions facing a looming deadline to avert UN sanctions.
Several previous ceasefire agreements have been violated.
"This agreement says that peace has started to return to South Sudan," said Bashir.
The declaration, a copy of which was made available to AFP, stipulates that the ceasefire arrangement includes disengagement, separation of forces in close proximity, withdrawal of all allied troops, opening of humanitarian corridors, and the release of prisoners of war and political detainees.
The agreement also allows members of the African Union and the Intergovernmental Authority on Development (IGAD) -- an East African regional grouping that has been pushing peace efforts -- to "deploy the necessary forces to supervise the agreed permanent ceasefire".
"The security arrangements that shall be adopted shall aim at building national army, police and other security organs of an all-inclusive character that shall be free from tribalism and ethnic affiliations," the document says.
"Policies shall also be agreed upon for the disarmament of civilians all over the country."
Wednesday's declaration says a transitional government will be formed within 120 days which will govern the country for 36 months.
"During the transitional period the country shall be prepared for national elections," it says.
"It is agreed that the election shall be open for all political parties and shall be free and fair."
The agreement says South Sudan in collaboration with Sudan would rehabilitate oilfield blocks 1, 2, 4 and 5A in Unity State in order to bring the country's oil production to its previous levels.
During the war, oil production -- from which South Sudan gained 98 percent of its revenues on its independence -- has plummeted to about 120,000 barrels a day from a peak of 350,000, according to the World Bank.
The Khartoum talks commenced on Monday and are scheduled to last for two weeks, after which the next round of negotiations will be held in Nairobi. A last round of dialogue is expected in Addis Ababa.
South Sudan's war broke out in December 2013 when Kiir accused his then vice president Machar of plotting a coup, dashing the optimism that accompanied independence from Sudan just two years earlier.
The new country quickly descended into civil war, including fighting within the national army, undermined by differences fuelled by the rivalry between Kiir and Machar.
The conflict spread to several states and was characterised by ethnic massacres, attacks on civilians, widespread rape, the recruitment of child soldiers and other forms of brutality and human rights violations.
A 2015 peace deal saw Machar reinstalled as vice president and return to Juba, but fighting broke out there in July 2016, forcing Machar out of the capital and into exile in South Africa.
The war has left the oil-rich country's economy in ruins and agriculture heavily disrupted.
Seven million South Sudanese, more than half of the population, will need food aid in 2018, according to the United Nations.