JUBA (Reuters) - South Sudan’s former vice president Riek Machar will be reinstated in his position as part of a peace deal to end a near five-year-old war that has killed tens of thousands and devastated Africa’s youngest nation.

FILE PHOTO: South Sudan rebel leader Riek Machar Kiir attends the signing in Khartoum, Sudan of an accord with the South Sudan government aimed at ending the country's civil war, June 27, 2018. REUTERS/Mohamed Nureldin Abdallah/File Photo

The agreement was reached in talks held in Entebbe in Uganda mediated by President Yoweri Miseveni and attended by South Sudan President Salva Kiir, Sudan’s President Omar al-Bashir and Machar, the country’s presidency said in a statement.

“After a 10-hour-long meeting, the parties agreed ... there will be four vice presidents and Dr Riek Machar will be reinstated as first vice president,” the statement said.

It added that although the government and the opposition had agreed to the proposal, “there will be more consultation to come up with the final decision”.

South Sudan has been gripped by civil war since 2013, when a political disagreement between Kiir and Machar exploded into a military confrontation.

Puok Both Baluang, the opposition SPLM-IO’s deputy spokesman, told Reuters they had no immediate comment on the statement from the presidency.

The war, which has mostly seen Kiir’s Dinka and Machar’s Nuer ethnic group pitted against each other, has killed tens of thousands, uprooted about a quarter of the country’s population of 12 million and slashed oil production, on which the economy depends almost entirely.

The agreement on Machar’s position marks a potential breakthrough in new efforts mediated by regional leaders to find a power-sharing and peace agreement to end the war.

A similar deal in 2015 failed the following year after Machar returned to the capital and disagreements quickly developed, reigniting fighting.

On Friday the government and opposition signed an agreement on security arrangements which follow on from a ceasefire deal last month, both crucial steps toward a final peace pact.