What the Afghan power-sharing deal means
The two rivals for the Afghan presidency, Ashraf Ghani and Abdullah Abdullah, have signed a power-sharing agreement, after a two-month audit of disputed election results. BBC Afghanistan correspondent David Loyn has seen a copy of the final document.
The deal that ends almost six months of wrangling was finally agreed late on Saturday night.
It was signed by the two candidates on Sunday - in the presence of outgoing President Hamid Karzai and the two international officials who have kept the process on the rails - the UN chief in Afghanistan, Jan Kubis, and US ambassador James Cunningham.
The four-page deal outlines the powers of a new post of CEO, chief executive officer, a post similar to a prime minister. Ashraf Ghani will be president, and Abdullah Abdullah will nominate the CEO.
There is considerable speculation that Dr Abdullah will not take this post himself. He has won a significant victory in ensuring that the CEO and his deputies "will be introduced at the presidential inauguration ceremony". The signing ceremony will now take place before any announcement of the election result.
This has been an obstacle that has taken weeks to resolve. Mr Ghani had argued that - under the constitution - the result of the election should be announced, then the president sworn in, before the formation of the national unity government.
The talks went up to the wire. In the next few days, the Afghan Election Commission will be ready to announce the final result of the intensive two-month long audit of the election. Many of Dr Abdullah's supporters do not accept that this was a fair process, and had threatened to take to the streets, staging violent protests.
'Answerable to president'
The new Afghan government will have a cabinet of ministers, including the CEO and two deputies, chaired by the president who will take strategic decisions. Day-to-day administration will be carried out by a new Council of Ministers, chaired by the CEO, and including all ministers.
One major issue that divided both camps was over appointments. In a country where patronage networks are still very powerful, the national unity government will find it hard to satisfy all of the high expectations raised by the election. Dr Abdullah won the fight to be able to appoint senior positions on terms of "parity" with Dr Ghani, and "the two teams will be equally represented at the leadership level".
But appointments further down will be "equitably" shared - so there will not be a one-for-one handout of jobs across the country. Dr Ghani is impatient to make major reforms, and has secured the wording he wants on the formation of a "merit-based" mechanism to appoint senior officials.
An official announcement of how many votes each candidate won is still awaited - one source told me the margin of victory could be as close as 3% but other figures being quoted by Afghan officials say it's more like 10%. Nothing is certain unless or until Afghanistan's Independent Election Commission publishes the final result.
The CEO will be "answerable to the president", who remains the most powerful figure in the government. And the document appeals for the two teams to govern together in a spirit of partnership, remembering their responsibility to the people of Afghanistan. But they disagree on so much, and after a bitter election campaign and months of wrangling, stability of this government cannot be guaranteed.
One aspect over which there was no disagreement was the need for electoral reform. The prolonged chaos this year following voting was caused by previous failure to introduce an electoral register. Both candidates have agreed to introduce electronic identity cards to all voters "as quickly as possible". A special commission will be appointed to introduce further reforms in time for next year's parliamentary election.
Update 22 September 2014: This article has been amended to make clear that the official vote tallies for each candidate have not yet been confirmed.