Rebel leader Riek Machar.

South Sudan on Friday set free James Gatdet Dak, a spokesman for rebel leader Riek Machar. and William John Endley, a retired South African soldier who was earlier sentenced to death and life imprisonment on treason and terrorism charges.

Minister of Interior Michael Changjiek said the two were released from the Juba central prison following President Salva Kiir's order issued on Wednesday, during the peace day celebrations that were attended by Machar, the leader of the Sudan People's Liberation Army-in opposition (SPLA-IO), and four other African leaders.

Kiir and Machar signed the final revitalized peace agreement to end over four years of conflict in September in the Ethiopian capital, which calls on both sides to immediately cease hostilities and release political detainees.

Both Endley and Gatdet were sentenced to death in February by the apex court in the capital. Gatdet was captured and extradited to Juba from Nairobi in November 2017.

Anthony Oliver Legge, spokesperson for the National Prison Service, said Endley will be immediately deported to South Africa and that these were the last group of political prisoners at the main prison.

He said the release of Endley and Gatdet represents the spirit of the revitalized agreement.

"Our brothers in the International Committee of the Red Cross (ICRC)... acknowledge the process and they are satisfied with the procedure," Legge said.

South Sudan descended into civil war in late 2013, creating one of the fastest growing refugee crises in the world.

A peace agreement signed in 2015 to end the violence was again violated in July 2016, when the rival factions resumed fighting in the capital, Juba, forcing Machar to flee into exile.

The United Nations estimates that about 4 million South Sudanese have been displaced internally and externally.