Former finance minister Ashraf Ghani was named Afghanistan's president-elect yesterday after he signed a deal to share power with his opponent, ending months of turmoil over a disputed election that destabilised the nation as most foreign troops prepare to leave.

Final election numbers were withheld at the announcement, apparently as part of the political deal between Ghani and rival Abdullah Abdullah, a former foreign minister who claimed the process was rigged against him.

"The Independent Election Commission of Afghanistan declares Dr Ashraf Ghani Ahmadzai as the president of Afghanistan," commission chief Ahmad Yousuf Nuristani said.

Full results would be provided at a later date, Nuristani said, but he did not say when. He acknowledged deep flaws in the June 14 run-off vote and said a UN-supervised audit was not adequate to weed out all the vote-rigging.

"Although the audit was comprehensive ... it could not detect or throw out fraud completely," Nuristani said, without taking further questions.

Under the terms of the unity government deal signed yesterday, Ghani will share power with a chief executive proposed by Abdullah. The two will share control over who leads key institutions such as the Afghan army, and other executive decisions.

The new administration faces huge challenges in fighting an emboldened Taliban-led insurgency and paying its bills amid plummeting tax revenue.

It will also face significant difficulty in improving the lives of Afghans who face hard times as aid flows fall and as contracts with the NATO-led coalition dry up as most foreign troops leave by the end of the year.

The accord signed yesterday was the finalisation of a broader power-sharing structure brokered by US Secretary of State John Kerry, who swiftly welcomed its signing.

"These two men have put the people of Afghanistan first, and they've ensured that the first peaceful democratic transition in the history of their country begins with national unity."

One of Ghani's first acts will be to sign a long-delayed bilateral security agreement with the US. He has already declared support for the pact to let a small force of foreign troops stay in Afghanistan after 2014.

Any instability could be exploited by neighbours such as Pakistan, which 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 US official in Kabul.

"Having them both working together within the government and direct their energies toward positive reform is again preferable to some of the alternatives."