South Sudan's President Salva Kiir and rebel leader Riek Machar have reached a ceasefire agreement during talks held in Ethiopia in a bid to bring the months-long bloody conflict to an end.

The rivals have called for a truce with immediate effect and also agreed to pave the way for a transitional government to lead the strife-torn South Sudan, the world's youngest country.

This is the first time the rivals are holding face-to-face talks since hostilities broke out five months back, amid fears that the strife could snowball into genocide.

"Now we have come to our senses...dialogue is the only answer to whatever problem we had. We will continue to move in the right direction," said Kiir following the agreement.

It is still unclear who will be part of the interim administration which will eventually take the country towards fresh elections scheduled for 2015.

Within 24 hours, both sides agreed to pull back their forces and to abstain from any provocative action. Under the deal, a new constitution will be in place following the elections.

Ethiopian Prime Minister Hailemariam Desalegn who hosted the talks also signed the agreement.

US Secretary John Kerry hailed the move saying: "Today's agreement to immediately stop the fighting in South Sudan and to negotiate a transitional government could mark a breakthrough for the future of South Sudan."

"The hard journey on a long road begins now and the work must continue. I saw with my own eyes last week the stakes and the struggles in a new nation we helped courageous people create. The people of South Sudan have suffered too much for far too long."

Kerry played a vital role in bringing the rivals together.

A similar agreement earlier this year failed to quell the violence as the two sides blamed each other.

President Kiir, an ethnic Dinka, had accused ousted former vice-president Riek Machar, who hails from the Nuer tribe, of attempting a coup against the government leading to clashes in December 2013. Machar denied the allegations.