US Secretary of State John Kerry last night brokered a deal with Afghanistan's two presidential election candidates that is hoped will resolve a dispute over the result of last month's vote.
Speaking alongside both candidates at a press conference in Kabul, Kerry said Ashraf Ghani and Abdullah Abdullah would abide by the result.
The recount of all eight million ballots would begin within 24 hours, Kerry confirmed.
The deadlock over the June 14 election run-off between the two leading contenders, has raised concerns in Washington about a smooth transition of power in Afghanistan just as US troops are withdrawing.
Kerry and his aides held late night meetings following talks on Friday with both Abdullah and Ghani, as well as with incumbent President Hamid Karzai and UN special envoy to Afghanistan, Jan Kubis.
He met again with Abdullah and Ghani at the US compound yesterday and met Karzai later at the presidential palace.
The talks continued as officials yesterday confirmed eight civilians, including five women, were killed when a roadside bomb blew up their vehicle in southern Afghanistan.
The United Nations said last week that the Afghan war was inflicting an increasingly devastating toll on civilians, with the number of casualties rising by almost a quarter in the first half of this year.
On the political level, preliminary results from the election run-off vote put Ghani, a former World Bank official, in the lead by almost one million votes. Abdullah rejected the result, claiming widespread fraud and calling the outcome a "coup" against the Afghan people.
The United States had urged the Independent Electoral Commission not to release the final vote tally until a thorough review of the votes. It also urged the camps of both Ghani and Abdullah not to declare victory.
As talks with Kerry unfolded behind closed doors, the rival camps initially remained tight-lipped on any progress until last night's news conference scheduled before Kerry flew to Vienna for talks between world powers and Iran on Tehran's nuclear programme.
Discussions between Kerry and the Afghan parties had focused on the technical details of the election process and the scope of an audit of the votes that would be acceptable to both sides. It has also looked at ways in which Afghanistan could set up an inclusive and broad-based government.