South Sudan's warring factions and leaders have vowed to end violence in the country and form a transitional government within 60 days.

The agreement was the result of a rare meeting in the Ethiopian capital Addis Ababa between former vice-president and rebel leader Riek Machar and South Sudan's President Salva Kiir.

The meeting was chaired by Ethiopia's prime minister Hailemariam Dessalegn, and it was mediated by the Inter-Governmental Authority on Development (IGAD).

Both leaders committed themselves to the formation of a transitional government and to ensuring unhindered humanitarian support to affected people with immediate effect, IGAD said.

Kiir and Machar reached a ceasefire deal earlier in February, but this failed to stem the violence as fresh fighting broke out shortly after.

Another ceasefire agreement was broken in May.

IGAD threatened both leaders it would apply sanctions if both parties do not respect the new agreement.

"If they don't abide to this agreement, IGAD as an organisation will act to implement peace in South Sudan," Desalegn said. "On that, we have different options including sanctions and [other] punitive actions as well.

"There has been a growing tendency to continue with the war," the prime minister added, criticising both factions for failing to abide with previous agreements.

After the meeting, Machar told Sudan Tribune that both leaders committed themselves to respecting the previous agreement and further negotiations on a peace agreement.

"We agreed on withdrawal of Ugandan troops," he added.

The withdrawal of Ugandan troops was a key request by the rebels, which refused to collaborate for a peace deal otherwise.

South Sudan Conflict Factbox

The conflict in South Sudan started last December when Kiir, from the ethnic Dinka group, fired the then prime minister Machar, an ethnic Nuer, and accused him of plotting to overthrow the regime.

Machar denied the allegations and accused Kiir of carrying out violent purges.

The accusations sparked violence among the two ethnic groups causing the death of thousands, leaving millions displaced.

Several NGOs have accused both warring sides of committing crimes against humanity including mutilation, rape and extrajudicial executions.

The UN mission in South Sudan (UNMISS) warned that hundreds of civilians were being killed due to their ethnic origins and nationality.

UNMISS also warned that radio stations were being used to broadcast hate speech.

Kiir warned the country was at risk of famine, if violence continues.