Ghani is expected to be sworn in as president on Sept. 29, according to a senior Afghan official.
The negotiated end to the crisis was far from the smooth election process that the U.S. and its allies had envisioned. They had hoped for an exemplary democratic transfer of power ahead of the end of the military mission that started with the 2001 ouster of the Islamist Taliban for sheltering al Qaeda leaders behind the 9/11 attacks on the United States.
Still, after weeks of election uncertainty that at times seemed about to descend into political and ethnic violence, the resolution was greeted with relief by many Afghans.
"The six-month election deadlock damaged life for Afghans," Kabul resident Mohammad Alim said. "We didn't have normal sleep, investors fled from Afghanistan, people were worried about their future ... but today people are relaxed and happy."
Read MoreChanges surround 9/11 anniversary commemoration
Besides the difficulties of forging an effective government after so much acrimony, Afghanistan's new administration faces huge challenges in fighting an emboldened Taliban-led insurgency that is launching near-daily attacks across the country.
It will also face significant difficulty in improving the lives of Afghans who face hard times as tax revenues plummet, aid flows fall and contracts with the NATO-led coalition dry up with most foreign troops leaving by the end of the year.
The accord signed on Sunday was the finalization of a broader power-sharing structure brokered by U.S. Secretary of State John Kerry, who swiftly welcomed its signing.
Speaking in New York before the start of U.N. meetings, Kerry said the naming of a new Afghan president was an opportunity to sign a bilateral security agreement with the United States.
Read MoreUS suspects more direct threats beyond ISIS
"They have joined together in a unity government that offers a huge opportunity for progress in Afghanistan, for the signing of the BSA in a week or so, inauguration next week for the new president, and importantly for a real program of unity and reform to be implement on behalf of the people of Afghanistan," Kerry said before a meeting with his French counterpart.
One of Ghani's first acts would be to sign the long-delayed security agreement as he has previously declared support for the pact to allow a small force of foreign troops to remain in Afghanistan after 2014.
There is a risk that any instability could be exploited by neighbors, like Pakistan, whose past involvement in Afghan affairs have played a part in the conflicts that have dogged Afghanistan for decades.
"A difficult and challenged unity structure is still preferable to conflict between these two groups," said a U.S. official in Kabul.
Read MorePakistan at risk of rating downgrade
"Having them both working together within the government and direct their energies toward positive reform is again preferable to some of the alternatives."
Ghani, an ethnic Pashtun, and Abdullah, whose main support comes from the country's second largest ethnic group, the Tajiks, face a difficult task forging unity in a country riven by ethnic and tribal rivalries.
Abdullah's accusations that the run-off election was rigged in Ghani's favour had raised fears of ethnic violence, which could have ignited a broader conflict.
"A spark could have dealt a strong blow to the political process, if today's deal had not happened," commented Waliullah Rahmani, director of the Kabul Center for Strategic Studies.
Read MoreHow ISIS is helping the GOP
"Afghanistan will now be able to move forward for the next five years, he said, "Even though it is not an ideal government."