* Kerry in Kabul to mediate between feuding parties
* Ghani leads in vote, preliminary results show
* Disputed vote undermines smooth transition of power
By Lesley Wroughton and Maria Golovnina
KABUL, July 12 U.S. Secretary of State John Kerry scrambled to produce a deal by the end of Saturday to end Afghanistan's election crisis, meeting for the second day with the country's two presidential candidates and incumbent President Hamid Karzai.
The deadlock over the June 14 election run-off between the leading contenders, Abdullah Abdullah and Ashraf Ghani, has raised concerns in Washington about a smooth transition of power in Afghanistan just as U.S. troops are withdrawing.
Kerry and his aides met throughout the night, following talks on Friday with both Abdullah and Ghani, as well as with Karzai and U.N. special envoy to Afghanistan Jan Kubis.
He met again with Abdullah and Ghani at the U.S. compound on Saturday and will meet Karzai at the presidential palace later.
A news conference is scheduled for Saturday afternoon before Kerry flies to Vienna for talks between world powers and Iran on Tehran's nuclear program.
Preliminary results from the runoff 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 has urged the Independent Electoral Commision 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 unfolded behind closed doors, the rival camps were tight-lipped on the progress.
"In this meeting they both exchanged ideas," said Mahmoud Saikal, a key member of Abdullah's camp, speaking about the Friday meeting. "John Kerry wanted more information about all electoral problems."
Discussions between Kerry and the Afghan parties have so far 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.
U.S. officials declined to elaborate on the possibility of a unity government, an idea both candidates have rejected, according to a U.S. official.
"This is a divided nation along many lines and it's very important at this stage in this society to ensure that we build as inclusive and as broad-based and as unified a national government as possible," a senior administration official.
"It was a close election, regardless of what happens and what the audit comes back and finds."
"We need to ensure that all communities and constituencies identify themselves in the government and feel represented in the government that ultimately takes over," the official added.
In comments to reporters on Friday, Kerry said the transition to a self-reliant state hung in the balance unless the legitimacy of the election could be restored.
U.S. officials said several ideas were being discussed and that an overall proposal had not yet been presented by the Americans. Kerry cautioned both sides against abandoning efforts to reach a compromise, the U.S. official said.
Washington has warned of repercussions if either side declares victory and tries to grab power.
The United States is in the process of withdrawing its forces from Afghanistan after 12 years of fighting Taliban insurgents, but the country remains dependent on foreign aid. The U.S. is Afghanistan's biggest foreign donor. (Editing by Clarence Fernandez)