After a relatively successful first round of presidential elections in Afghanistan in April, the second round—held June 14—has led to a full-blown political crisis that jeopardizes both the future stability of the state and the hard-won development and security gains by U.S. and NATO forces over the last 12½ years.

If Afghans can’t achieve a peaceful resolution, they risk losing international support and aid and seeing their country devolve into an ethnic-based civil war.

This election would mark the first peaceful transfer of power from one democratically elected leader to another in Afghanistan’s history. It is imperative that Afghan political players demonstrate they can manage this transition.

In the first round of elections held on April 5, voter turnout reached an unprecedented 60 percent, as Afghans defied Taliban threats and violence to demonstrate their faith in the democratic process. But since no candidate received a majority of votes in the first round, a second round was held June 14 between former Afghan Foreign Minister Abdullah Abdullah and former Afghan Finance Minister Ashraf Ghani Ahmadzai.

Soon after the second round of voting concluded, Abdullah’s camp complained of election fraud and vote rigging. Abdullah said there was collusion between Ashraf Ghani’s staff, the staff of the Independent Election Commission and members of President Karzai’s administration.

Despite angry street protests by Abdullah supporters and calls for a delay in the announcement of the vote tally until the irregularities could be addressed, the IEC announced preliminary results indicating Ghani won the second round with 56.44 percent of the vote. Official results are expected to be announced July 22, with the new president inaugurated on Aug. 2.

Abdullah has threatened to establish a parallel government and has said he will accept the results only if fraudulent votes are thrown out. Abdullah wants a recount of votes from pro-Ghani provinces, where turnout was said to have tripled from the first round of voting. He says there is a discrepancy of about 2 million votes when results are compared with the IEC’s initial data. The Abdullah camp released audio tapes allegedly documenting the fraud, including statements by one IEC official using code words to order a local official to stuff ballot boxes.

U.S. Secretary of State John Kerry travels to Kabul on Friday to try to mediate a solution. He played a helpful role in resolving an electoral crisis in Afghanistan in 2009, when he convinced Abdullah Abdullah to back away from demands to hold a runoff election against Karzai. But Abdullah has shown he is in no mood to back down a second time.

Abdullah, Ghani, and Karzai should recognize the importance of resolving the electoral crisis peacefully so as not to lend advantage to Taliban insurgents, who are currently engaged in an offensive in southern Helmand province and likely will be inspired by ISIS gains in Iraq to push their fight forward.

A prolonged election dispute and failure to establish a legitimate successor government also would jeopardize the U.S. ability to leave troops in Afghanistan post-2014, which requires the new Afghan government to sign a bilateral security agreement defining the terms of the U.S. deployment.