The deal, mediated by Sudan and signed in the Ethiopian capital Addis Ababa, reinstated Machar in his former role as vice president and comes two weeks after a peace deal was officially agreed upon between the government and rebel groups.
“The eyes of the world are upon us as the South Sudan leaders commit today to press for reconciliation and lasting peace in their country,” Ethiopian Prime Minister Abiy Ahmed said ahead of the signing.
About four million South Sudanese were displaced in half a decade of fighting.
Government spokesman Ateny Wek Ateny told The Associated Press that Kiir, Machar and other opposition parties signed the “final final” deal. He said the agreement is acceptable to all parties and noted Kiir and Machar had an amicable chat.
Previous peace deals have held for only a matter of months before fighting resumed, and in late August Machar caused worry among negotiators by refusing to sign.
Wednesday’s agreement was met with cautious optimism by David Shearer, head of the United Nations Mission in South Sudan.
“With the signing of this revitalised agreement, we should publicly acknowledge it is but one step on the road to peace, but one which lays the foundation for all that follows,” he said.
The three countries that oversaw peace efforts in the country, the United States, the United Kingdom and Norway, echoed Shearer’s concerns.
“We hope discussions will remain open to those who are not yet convinced of the sustainability of this agreement. We must seize this broader regional momentum to secure peace for the people of South Sudan,” they said in a statement.
“We hope discussions will remain open to those who are not yet convinced of the sustainability of this agreement.”
Kiir has blamed the collapse of previous peace agreements on foreign influence.
The warring parties have held weeks of talks in Khartoum in search of a comprehensive peace deal to end the conflict.
In June, an initial agreement was signed to end the fighting, but Machar rejected some proposals such as having three different capitals to distribute power.
South Sudan descended into civil war in 2013, shortly after independence in 2011, after Kiir accused Machar, then his deputy, of plotting a coup.
Last July, the UN issued an arms embargo and sanctions on two military officials in an attempt to force the warring parties to the table.
The war has uprooted one-quarter of South Sudan’s population of 12 million, ruined the country’s agriculture sector, and battered its economy.
South Sudan resumed pumping 20,000 barrels a day of crude oil from the Toma South oilfield last month, where production had been suspended since 2013 because of the civil war.
Income from oil accounts for 98 percent of the country’s budget.