* Election marred by allegations of fraud
* Rivals discussed further audits, prolonging count
* Final results due on July 22 (Adds election result)
By Mirwais Harooni and Maria Golovnina
KABUL, July 7 (Reuters) - Afghanistan declared former World Bank official Ashraf Ghani the winner of last month's presidential election on Monday on the basis of preliminary results from a messy vote that has threatened to split the country along ethnic lines.
Ghani's rival, Abdullah Abdullah, claimed widespread fraud in the election and insisted the announcement of results should be delayed until all fraudulent votes were thrown out.
Abdullah, a former anti-Taliban fighter, was not immediately available for comment on Monday. A bloody standoff between ethnic groups or even secession of parts of the country is possible if he refuses to accept the outcome.
The Independent Election Commission said Ghani won the June 14 second-round run-off with 56.44 percent of the vote, according to preliminary results.
The numbers and outcome still might change, however, when final, official numbers come out on July 22.
The deadlock over the vote has quashed hopes for a smooth transition of power in Afghanistan, a concern for the West as most U.S.-led forces continue to withdraw from the country this year.
Earlier on Monday, rival camps struggled to find a last-minute compromise to keep Afghanistan from sliding into a protracted period of uncertainty without a clear leader accepted by all sides.
Abdullah, who has a Pashtun father and a Tajik mother, draws much of his support from the Tajik minority in northern Afghanistan. Ghani has strong support from Pashtun tribes in the country's south and east.
Without a clear, unifying leader, Afghanistan could split into two or more fiefdoms along tribal fault lines, or even return to the bloody civil war of the 1990s.
Abdullah has accused Karzai, also a Pashtun, of playing a role in the alleged rigging in Ghani's favour and says he would accept the vote only if he saw firm evidence that fraudulent votes had been thrown out and the final result was clean.
As their standoff intensified in past weeks, Afghanistan has been full of talk about a broader rift along ethnic lines or even violence unless they agree to accept the outcome of the vote or come to a compromise arrangement.
Taliban insurgents remain a formidable security risk after vowing to disrupt the election process. On Monday, they killed a district police chief in the western city of Herat and attacked a check point in northern Afghanistan. (Writing by Maria Golovnina; Editing by Sonya Hepinstall)
Our Standards: The Thomson Reuters Trust Principles.