The deal calls for an immediate ceasefire and the formation of an interim Government before a new Constitution and new elections.
The conflict in the world's newest State left thousands dead and more than 1 million homeless.
A ceasefire agreed in January broke within few days with both sides accusing each other restarting the fighting.
US Secretary of State John Kerry said agreement on Friday "A breakthrough for the future of South Sudan might mark".
"Now begins the hard journey a long way the work must be continued,", added Mr Kerry, played a pivotal role in the bringing together of the two sides.
Rebels and Government forces have fought since December in the latest state of the world members of the White Army against the Government militia. The conflict has thousands of deathsThe UN has the southern Sudanese Government and the rebels of crimes against humanity, including mass murder and gang-rape accused.
The agreement in the Ethiopian capital Addis Abeba signed the rival late on Friday, after their first face-to-face meeting since the beginning of hostilities.
The BBCs Emmanuel Igunza in Addis Abeba says that calls for cessation of hostilities within 24 hours after the signing of the agreement. A permanent ceasefire will be processed then.
Yet say whether this will be the final breakthrough, says Mariko OiMr Kiir and Mr Machar are immediate orders for troops to stop fighting and to allow in humanitarian aid.
It was not immediately clear who would make up the Transitional Government.
"Widespread atrocities"The agreement was signed by Ethiopian Prime Minister Hailemariam Desalegn, the the talks.
Leading broker Seyoum Mesfin, from the regional IGAD bloc, congratulated Mr Kiir and Mr Machar for "End of war".But African Union official Smail Chergui warned that "given the current crisis, the restoration of peace in southern Sudan are not easy".
A UN report released on Thursday said that "widespread and systematic" had been carried out atrocities in homes, hospitals, mosques, churches and UN connections from both sides.
It called for those responsible who will be held accountable.
An estimated 5 million people need aid, the UN says.
The violence began when President Kiir accused of his sacked Deputy, Mr Machar plotting a coup.
Mr Machar denied the claim, but then to combat rebel army marshaled to the Government.
The BBC describes the background to South Sudan crisis - in 60 seconds.The battle ethnic undertones adopted by Mr Machar strongly on fighters from his Nuer ethnic group and Mr Kiir from his Dinka community.
The UN has about 8,500 peacekeeping troops in southern Sudan. However, they have struggled to contain the conflict.
In South Sudan Independence break away from Sudan after decades of conflict between the rebels and the Government in Khartoum in the year 2011.
It remains one of the poorest countries in the world.
Fighting in the capital broke South Sudan Juba, mid-December. This was followed by a political power struggle between President Salva Kiir and his ex-Deputy Riek Machar. The dispute has an ethnic dimension reference to politicians often are ethnic political base. Sudanese arid north is mainly home to Muslims speaking Arabic. But there is no dominant culture in southern Sudan. The largest more than 200 ethnic groups with their own languages and traditional beliefs, along with Christianity and Islam are the Dinkas and the Nuers. Both Sudan and to the South are reliant on oil revenue, which accounts for 98% of the South Sudan budget. You violently objected to sharing the oil wealth of the former united - was at one time the production shut down for more than a year. About 75% of the oil is in the South, but all pipelines North run. The two of Sudan are geographically very different. The large ditch is visible even from space, because this NASA satellite image shows. The Northern States are a blanket of the desert, punctuated only by the fertile Nile River corridor. South Sudan is covered with green tracts of land, grassland, swamps and tropical rain forest. After the independence was in the year 2011 in southern Sudan is the latest country - and one of the world's poorest. Figures for 2010 show 69 percent of households now have access to clean water - up from 48% in 2006. However, only 2% of households water on the site have. Only 29% of children go to primary school in southern Sudan – this is also an improvement of 16% recorded in 2006. About 32% of the primary-age young take part, while only 25% of girls do. Overall, 64% of children who start primary school reach the last stage. Nearly 28% of children under five in South Sudan are moderately or severely underweight. Compared with the 33%, 2006 recorded in the year. Unity State has the highest proportion of children, which, has the lowest (17%) to malnutrition (46%) during Central Equatoria.