By Matthew Rosenberg and Carlotta Gall

New York Times News Service

KABUL, Afghanistan — The Obama administration had hoped that after years of frustration with President Hamid Karzai, a successful election in Afghanistan would finally produce a leader who could stabilize the country while working with the United States to allow an orderly withdrawal of U.S. troops and end its longest war.

Yet nearly a month after a runoff election to choose Afghanistan’s next president, Secretary of State John Kerry arrived here Friday for a visit aimed at resolving a crisis that began with allegations of widespread vote rigging. It now threatens to fracture Afghanistan’s fragile government as U.S.-led combat troops are preparing to complete their withdrawal.

Both candidates, Abdullah Abdullah and Ashraf Ghani Ahmadzai, have acknowledged that fraud marred the election, and yet each campaign has claimed victory, with Abdullah this week threatening to declare himself president, raising the specter of an ethnically and regionally divided Afghanistan.

Overshadowed by the events in Iraq, the swift deterioration of the political situation here has, in a matter of weeks, moved Afghanistan dangerously close to a situation far worse than that envisioned as likely by many U.S. and Afghan officials before the election.

The prospect that Abdullah, who has the support of many powerful former warlords, might try to seize power prompted U.S. and European officials to threaten in recent days that foreign troops could be pulled out and billions of dollars in essential aid lost if the crisis was not peacefully resolved.

U.S. officials said Friday that standing on the sidelines risked the possible fracturing of a government the United States has spent billions to build and lost thousands of soldiers to defend. Current and former Afghan officials concurred, stressing that a solution was still possible, but that time was running out.

Adding to the complications faced by Kerry, salvaging the Afghan election means working with the person the Obama administration is most eager to see gone: Karzai.

The Afghan leader remains powerful even as a lame duck. Afghan officials close to him have said he has shaped the election process in favor of Ahmadzai, a longtime adviser and former finance minister who held a commanding lead in preliminary results released Monday.

Kerry met separately Friday with Karzai, Abdullah and Ahmadzai. The focus was on the technical aspects of the election process, specifically on seeking an audit of votes suspected to be fraudulent, an issue at the center of the deadlock.

A senior aide to Abdullah said that the candidate left his meeting with the sense he had finally gotten a fair hearing after weeks of being told by Western officials to respect a process he believes is irredeemably tainted in Ahmadzai’s favor.