By Mirwais Harooni and Maria Golovnina
KABUL (Reuters) - The euphoria over a U.S.-brokered deal between Afghanistan's rival presidential candidates at the weekend was a sign of how close some people believe the country came to a split along ethnic lines that could quickly turn violent.
The speed at which that relief has evaporated suggests the political crisis, playing out as foreign troops prepare to withdraw after more than a decade policing the war-torn nation, is not over yet.
And while Afghans and foreign governments fret over the fate of the election, an insurgency led by the ousted Taliban militia rages on. On Tuesday, at least 89 people were killed when a car bomb exploded in a crowded market in the eastern province of Paktika, one of the worst attacks in a year.
U.S. Secretary of State John Kerry flew to Kabul last week to secure a political agreement between Abdullah Abdullah and Ashraf Ghani, who contested a June 14 run-off presidential vote, the results of which are still in dispute.
The solution that pacified both parties, at least for now, was an ambitious, U.N.-supervised recount of all eight million votes cast - an exercise aimed at appeasing Abdullah who has alleged mass fraud and refuses to accept defeat.
It is designed both to weed out illegal votes and soften the blow for the losing candidate by introducing the idea of a unity government in which there would be both a president and a prime minister who would enjoy some powers.
But in a country where infrastructure is basic, it is a mammoth task that could take weeks, and there is no clear indication yet as to how fraudulent ballots will be identified and eliminated.
"While we all took a collective sigh of relief on Saturday night, the hard work is still before us, both on the technical process given all the logistical challenges ... as well as the other part of this ... which is the political process," said a senior U.S. official.
WILL ANYONE ACCEPT DEFEAT?
Abdullah's allies, largely drawn from the Tajik minority based in the north of the country, have said they will not necessarily accept the outcome of a recount if it goes the same way as the preliminary tally.
Mohammad Khan, Abdullah's first vice president, said if there were signs of further fraud, or if the camp was not satisfied by the findings of the Independent Election Commission, the result would be unacceptable.
"If we find any sign of fraud ... we will not accept the results. It's too early to say what our next plan is."
Preliminary results from the vote put Ghani, who comes from the Pashtun majority based in the east and south, in the lead by about a million votes - a result fiercely disputed by Abdullah and questioned by some independent observers.
Even if Abdullah accepted the recount, he may not be able to control all of his supporters.
The suave former foreign minister, who fought against the Taliban when the hardline Islamist movement ruled Afghanistan in the late 1990s, opposes a violent solution to the crisis.
But at the height of the tensions earlier this month, groups of men angered by the election result cruised around Kabul shooting in the air and shouting pro-Abdullah slogans.
In Afghanistan, where ethnic divisions run deep, political disputes can quickly descend into chaos.
TENSIONS EASE, FOR NOW
The bitter standoff quashed hopes for a smooth transition of power from President Hamid Karzai, who has run Afghanistan since a U.S.-led war toppled the Taliban in 2001.
But last week's deal did succeed in reducing tensions, and, as preparations for the recount get underway, Abdullah and Ghani have visited each other's homes in Kabul this week to map out the future and cement the deal.
Sources said they were discussing a national unity government that would include representatives of the losing camp. Under the proposal, the president would appoint a chief executive, a role which can later be changed to prime minister.
Because of the huge logistical challenges, U.N. special representative for Afghanistan Jan Kubis has asked for a month's delay to the inauguration of a new president, which was to have taken place on Aug. 2, according to a statement from Karzai.
The Independent Election Commission said it would bring ballot boxes from almost 23,000 polling stations to Kabul and each of the ballots cast would be individually examined.
It said it would take three weeks to inspect the votes, but some fear it could take longer, a worry for the United States which is keen to sign a security agreement with a new leader allowing some U.S. troops to remain in the country beyond 2014.
The senior U.S. administration official said that if the schedule slipped by just a few weeks it would not be a problem.
"We're really in a fairly fluid period right now," he said.
"We don't expect it to be more than that few weeks, but we also don't want to put artificial deadlines on it. And if it only slips by a few weeks, then I don't expect that there will be much impact on the issues that you laid out."
Worryingly, U.S.-led forces in Afghanistan, who are assisting in transporting the ballot boxes to Kabul from across Afghanistan's rugged terrain, said the process had yet to start.
"We do not know when the movement of the ballot boxes will begin, or how long it will take," the International Security Assistance Force said in an email to Reuters.
"The process of transferring the ballot boxes to Kabul has not started, so far as we are aware."
There are also questions about the criteria officials will apply to identify fraudulent votes. Nader Mohseni, a spokesman for the Electoral Complaints Commission, said votes marked by wrong pens or not properly signed or stamped by a station chief would be discounted.
He ruled out the possibility of a repeat election, a scenario some had feared, saying the result of the audit would have to be accepted by all sides.
"There is no possibility of a new presidential election, because in the second round...any candidate who got 50 (percent) plus one vote will be announced as the winner," he said.
(Additional reporting by Missy Ryan, Writing by Maria Golovnina; Editing by Mike Collett-White)