The signing – broadcast live on national TV – comes after months of wrangling following presidential elections in April and June.
Under the deal, Ashraf Ghani becomes president while runner-up Abdullah Abdullah nominates a CEO with powers similar to those of prime minister.
Both sides had accused the other of fraud following the election.
The final result of the bitterly contested poll is due to be announced later.
Ashraf Ghani and Abdullah Abdullah signed the agreement at a ceremony inside the presidential palace in the capital, Kabul. They then stood and embraced each other.
The power-sharing deal was finally reached after a comprehensive audit of all eight million votes which began in July.
The agreement says the new CEO will be answerable to Ashraf Ghani, although he has lost a battle to be sworn in after the announcement of the election result.
Instead, the two men have signed the national unity agreement before the election result is announced.
The new chief executive – nominated by Abdullah Abdullah – will be side-by-side with the president when he is inaugurated.
Abdullah Abdullah will be able to appoint senior positions on terms of “parity” with Ashraf Ghani. The agreement says “the two teams will be equally represented at the leadership level”.
However, there will not be a one-for-one handout of jobs further down and that could lead to arguments.
The agreement calls for a spirit of partnership. But after a bitter election campaign and months of wrangling, the stability of this government cannot be guaranteed, he adds.
A spokesman for Ashraf Ghani said that there was no longer any dispute between the two sides.
“Both camps have agreed 100% on everything and we’ll sign the deal tomorrow,” Faizullah Zaki told Reuters on Saturday, September 20.
The audit of ballots was part of a deal brokered in July by Secretary of State John Kerry to try to avert a descent into violence.
Both candidates pledged to accept the audit results and form a unity government.
One of the new president’s first tasks is widely expected to be signing a bilateral security agreement with the US.
The deal will allow a small force of soldiers to remain beyond 2014 to train Afghan security forces.
Incumbent President Hamid Karzai has refused to sign the security agreement, which is linked to the continuation of aid needed to pay Afghan civil servants, teachers and soldiers.
Ashraf Ghani and Abdullah Abdullah have both promised to sign the agreement.
E5V6U7IjuT0Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…