By Kay Johnson and Mirwais Harooni
KABUL (Reuters) - The rival candidates in Afghanistan's messy election for a new president finally struck a power-sharing deal on Saturday, aides said, after more than two months of tension over a vote in which each side accused the other of fraud.
The crisis has further destabilised Afghanistan just as the U.S.-led military coalition prepares to withdraw most foreign troops at the end in the year, leaving Afghan forces to fight the Taliban insurgency.
Teams from both sides had met late into the night with United Nations representatives to try to finalise a power-sharing deal before Sunday's scheduled announcement of the final election results after a U.N.-monitored audit and recount.
"Both camps have agreed 100 percent on everything and we'll sign the deal tomorrow. Everything has been initialled and there is no disagreement on anything," said Faizullah Zaki, spokesman for front-running candidate and former finance minister Ashraf Ghani.
Mujib Rahimi, spokesman for Abdullah, a former foreign minister, also confirmed a deal had finally been struck, but did not give any details.
Aimal Faizi, a spokesman for President Hamid Karzai, said the deal would be formally signed on Sunday in a ceremony with Karzai.
Preliminary results released in July put Ghani ahead with 56 percent of the vote, prompting street protests from supporters of Abdullah, who alleged massive fraud and said he was the rightful winner.
The dispute ruined hopes for a smooth democratic transition to replace Karzai, who has held power since the Taliban's hardline Islamist government was ousted in 2001 with U.S. military support, and threatened to rekindle the ethnic tensions that had 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, the largest ethnic group.
Final election results have been delayed for weeks to await an audit of all 8 million ballots cast in the June 14 run-off vote between Ghani and Abdullah, the top finishers in the first round in April.
The audit was part of a deal brokered in July by U.S. Secretary of State John Kerry to try to avert a descent into violence.
Both Abdullah and Ghani pledged to accept the audit results and to form a unity government, with the winner as president and the runner-up holding or nominating a chief executive with expanded powers. Wrangling over much power that chief executive will wield has been a key sticking point in the power-sharing deal.
(Additional reporting by Hamid Shalizi,; Editing by Kevin Liffey)