(Adds Kerry meeting candidates in paragraphs 4 and 5)
By Lesley Wroughton
KABUL, Aug 7 (Reuters) - U.S. Secretary of State John Kerry arrived in Afghanistan on Thursday for his second visit in under a month to push a deal between the country's two presidential candidates on how to share power after an audit of a disputed election is complete.
Ashraf Ghani and Abdullah Abdullah shook hands on an agreement to resolve the election row after Kerry's visit in July but they remain far apart on critical components of their pact to form a united government.
Although a painstaking audit of all eight million ballots cast in the second round of voting is under way, neither candidate has openly endorsed the process and the deadlock has raised the spectre of violent conflict along ethnic lines.
Afghanistan's Western backers hope the audit will produce a legitimate president before a NATO summit in early September. Shortly after arriving in Kabul, Kerry held separate meetings with Ghani and Abdullah at the U.S. compound to drive forward the deal.
He is expected to meet again with each of the candidates on Friday, and separately with President Hamid Karzai at the presidential palace, before a news conference.
While Karzai has said the next president will be inaugurated on Aug. 25, most officials involved in the process say the deadline is optimistic and it could take until the end of the month for a winner to emerge at the earliest.
"We are hopeful the secretary can obtain a commitment by both candidates to a timeline for completing the audit and agreeing on the details of a national unity government," said a senior State Department official who briefed reporters en route to Kabul.
NATO desperately wants Afghanistan to have a leader at the summit that was to be a crowning moment of its mission of more than a decade, and before Western combat troops withdraw at the end of 2014.
Under the deal agreed verbally during Kerry's last visit, the winning candidate will take the role of president and form a government of national unity, while the loser will assume the position of chief executive.
The structure of that government, however, still needs to be hammered out and the two candidates have widely divergent views on how it should function.
A Western diplomat said the candidates had a friendly meeting earlier this week, agreeing on five points, although much progress remained to be made.
Abdullah, the clear winner in the first round but who failed to secure an absolute majority, has blocked the election process by accusing Ghani and Karzai of colluding to skew the run-off result, which preliminary counts show Ghani won.
The eight million votes cast in the run-off election that was to mark Afghanistan's first democratic transfer of power in its history are currently being audited under the supervision of hundreds of international observers.
"We do have hopes that if this can be accelerated that it would be possible to meet our goal for a new president to be inaugurated and a government of national unity to be in place before the NATO summit," the State Department official said.
He said there had been no discussion yet of what might happen if a new president and government of national unity was not in place by the NATO summit.
Both candidates have said they remain committed to signing a bilateral security deal that Washington says it needs to keep some troops in Afghanistan beyond 2014.
"They will have a far greater chance of success if they can demonstrate they are the credible leadership of Afghanistan and are working together in a government of national unity to ensure there will be long-term stability in Afghanistan," the official added. (Additional reporting by Jessica Donati; Editing by Andrew Roche)