By Kay Johnson and Mirwais Harooni
KABUL (Reuters) - Rival candidates in the bitterly disputed Afghan presidential election will sign an agreement on a unity government on Sunday, aides said, potentially easing months of tension that destabilized Afghanistan while foreign troops withdraw.
The signing ceremony to be held at the Kabul presidential palace - still occupied by outgoing leader Hamid Karzai despite an election process that began in April - will coincide with the planned announcement of final results.
The announcement follows a U.N.-monitored audit of all 8 million ballots cast in a June run-off vote that had been disputed by both major candidates - former World Bank official Ashraf Ghani and former foreign minister Abdullah Abdullah.
Ghani and Abdullah struck a power-sharing deal on Saturday, their aides said. As part of that deal, former finance minister Ghani will most likely become the new president and Abdullah chief executive with newly expanded powers, although when those moves will come into effect remains far from clear.
The election was showcased by Afghanistan's foreign backers as the first democratic transfer of power in Afghanistan's troubled history but the drawn-out dispute ruined hopes for a smooth transition from Karzai, who has ruled since soon after the Taliban were ousted in late 2001.
The uncertainty emboldened the Taliban-led insurgency to launch more attacks across Afghanistan, just as the newly trained Afghan security forces prepare to lead the fight against the militants on their own after foreign troops withdraw.
Teams from the Ghani and Abdullah camps met late into Saturday night with U.N. representatives to try to finalize the power-sharing deal before the release of the audit results.
The final bone of contention had been how the final vote tally would be announced. Aides and officials have said Abdullah insisted that the official percentages of the votes either not be made public or be altered to give him more votes. Abdullah is widely seen as trailing Ghani in the tally.
It was unclear how the dispute over results was finally resolved but all sides in the talks said late on Saturday that the deal was done.
"Both camps have agreed 100 percent on everything ... Everything has been initialed and there is no disagreement on anything," said Faizullah Zaki, a spokesman for Ghani.
Abdullah spokesman Mujib Rahimi also confirmed a deal had been struck, but did not give any details.
Aimal Faizi, a spokesman for Karzai, said the deal would be formally signed at the presidential palace on Sunday. Faizi also said in a text message the candidates had agreed on the announcement of results but gave no other details.
Preliminary figures released in July put Ghani ahead with 56 percent of the June 14 run-off vote, prompting street protests from supporters of Abdullah who alleged massive fraud and said he was the rightful winner.
The political crisis threatened to rekindle the ethnic tensions that plunged Afghanistan into civil war in the 1990s. Abdullah derives much of his support from the ethnic Tajik and Hazara communities, while Ghani is widely supported by the Pashtuns, Afghanistan's largest ethnic group.
The audit of the June 14 run-off was part of a deal brokered in July by U.S. Secretary of State John Kerry to try to avert a descent into violence.
Abdullah and Ghani pledged to accept the audit results and form a unity government with the winner - presumably Ghani - as president and the runner-up either becoming chief executive or nominating someone for post with newly expanded powers.
Just how much power the chief executive would wield was one of the main stumbling blocks.
A draft of the agreement seen by Reuters would give the chief executive the power to decide on a near-equal number of key government positions. It also calls for the unity government to call a loya jirga - a traditional Afghan council of elders - to help reform election laws and prevent future crises.
One of the new president's first tasks will likely be signing a bilateral security agreement with the United States that would allow a force of a few thousand foreign soldiers to remain after 2014 to train Afghan security forces.
Karzai has refused to sign the document, which is linked to continuation of much-needed aid needed to pay Afghan civil servants, teachers and soldiers. Ghani and Abdullah have both promised to sign the agreement.
(Additional reporting by Jessica Donati; Editing by Paul Tait)