South Sudan: Obstacles to a lasting peace
This was a peace deal signed under duress - as President Salva Kiir made very clear in his speech.
So although millions of South Sudanese are rejoicing, there are legitimate doubts about whether the agreement will bring lasting peace.
Until Wednesday's dramatic signing ceremony, a year-and-a-half of peace processes had not stopped South Sudan's collapse.
Soldiers slaughtered young boys, women were raped and millions fled as ceasefires were ignored.
An expanded mediation team from the regional body Igad and several other interested nations, known as Igad Plus, pushed through this supposedly permanent peace deal.
Here are five of the main obstacles to a lasting peace in South Sudan:
1. The two main rivals
Do the leaders realise or care how much the people are suffering? Are both sides prepared to make the necessary compromises to end the war?
Will a tougher stance from the US and regional leaders make a difference? What about the growing economic crisis?
Mr Machar arguably has more to gain from the agreement: He will become first vice-president, his movement will get political posts and his troops will become integrated into the army. But what happens if he does not get everything he wants from the deal - or if he does not get the nomination of the governing SPLM party for the 2018 elections?
Mr Kiir has made it very clear he dislikes the deal - and his animosity with Mr Machar is well known too. Will Mr Kiir respect an agreement he feels was imposed upon him and South Sudan? Will he allow Mr Machar and his movement the powers the peace deal grants to them?
And can the two men, who have fought each both in the past and over the last 20 months, work together again?
Finally, what will happen if Mr Kiir, Mr Machar or other senior officials are found guilty of atrocities in the hybrid court that is to be set up?
2. The terms of the deal
President Kiir expressed his dissatisfaction with the deal, including some of the power-sharing and security components.
Many of his key supporters, including ethnic Dinka elders and powerful generals, had advised him not to sign it.
They say it is a foreign-backed attempt to weaken President Kiir and the country.
The rebels had objections too, but the fact they signed earlier suggests these were less serious.
South Sudanese civil society groups have also criticised the agreement for putting too much emphasis on power-sharing among the elite, rather than insisting on accountability and justice, or resolving the underlying issues that caused the conflict.
The government and the rebels have signed a power-sharing agreement, essentially fine-tuning a return to the status quo ante.
But if the root causes of the conflict aren't resolved, it is difficult to see it bringing lasting peace.
3. South Sudan's neighbours
Over the past 18 months, South Sudan's neighbours have taken a leading role in mediating between the warring parties.
Yet this has been compromised by their own involvement in the conflict.
Uganda intervened militarily in support of President Kiir, to the frustration of the rebels. Sudan is allegedly providing logistics, weapons and bases to Mr Machar's army.
Other countries are not implicated militarily in South Sudan, but have important economic interests there (Kenya) or wish to drive the mediation process (Ethiopia).
This peace deal will only last if all of South Sudan's divided neighbours value keeping the peace as much as the South Sudanese citizens do.
4. Unity on both sides
Mr Machar's rebel group was always an uneasy coalition of civilian militias and military units that defected from the national army, the SPLA.
The recent split announced by well-known generals including Peter Gadet and Gathoth Gatkuoth was no surprise: The men had been sidelined, in part because of their opposition to Mr Machar's apparent willingness to consider a power-sharing deal.
There had always been concern about whether Mr Machar could bring all his movement with him. Now we are about to find out.
Two key questions here: do the generals have enough support on the ground to constitute a powerful military force of their own?
And will they receive the external military support they will need to flourish?
This would be most likely to come from Sudan, as Gen Gadet has fought for Khartoum several times in the past.
Equally relevant here: Will all the hardliners in Mr Kiir's camp respect the agreement he has just signed?
His critics often accuse the army chief of staff, Paul Malong Awan, of wanting to scupper the peace process - but he is not the only potentially frustrated figure.
Many officials, in particular in Unity, Upper Nile and Jonglei states, stand to lose their jobs to rebels. How will they react?
5. Deepening ethnic animosity
Millions of South Sudanese have known hardly anything but war.
At the time of the united Sudan, the first north-south civil war lasted from 1955-1971, and the second was even longer (1983-2005).
After South Sudan's independence in 2011, it wasn't long before this new civil conflict erupted - in December 2013.
Tragically, war is part of life for many. South Sudan is a militarised society, where the military men run politics.
Those in command often have ethnic power bases, bringing an ethnic dimension to most conflicts.
The current war has deepened animosity between the Nuer and the Dinka, the country's two biggest ethnic groups.
The picture is even more complicated than this: for example, many Bul Nuer (a Nuer sub-group) have fought for the government against the largely Nuer rebels, creating tensions within the Nuer.
In South Sudanese society, the culture of revenge is also prominent - a worrying ingredient in a conflict in which tens of thousands have been killed.
All these factors will be difficult to resolve, even though a peace deal has been signed.
Nevertheless, the country has strong traditions of peace-making and reconciliation, often through the chiefs or the church.
Their best efforts will be needed if a lasting peace is to be achieved.