Now it will be up to the neighbors, who — despite all their differences — share an interest in seeing Afghanistan avoid a new bloodletting. They question the Afghan Army’s ability to defeat the Taliban in battle; the force is still largely made up of ethnic Tajiks and Hazaras from Afghanistan’s north and west, leaving it likely to provoke resistance among the Pashtuns of the embattled south and east, from whom the Taliban spring. The neighbors remember the collapse of an earlier Afghan army soon after the Soviets who had trained it left, as well as the decade of civil war that followed in the 1990s. No neighbor wants that experience repeated, and a regionally supported peace deal would be the surest way to dissuade outsiders from supporting any Afghans who did.

So how does the United States proceed?

It should keep reminding everyone that it is about to leave, and that it is in their own best interest to build a regional consensus for an Afghan peace. That means joining hands with the Americans to ensure that a strong president emerges from the messy election process.

On Election Day, the first reaction was relief at the turnout. But now there is concern that the final ballot count will prompt claims that the margin of fraud exceeds the margin of victory. The early first-round results point to a tight runoff race between Ashraf Ghani and Abdullah Abdullah, and a need for America to help broker a fair outcome, since a disputed outcome could divide the country.

America should call on Afghanistan’s neighbors to assist. Any political wrangling would draw in Iran as well as America, since the two nations have had the most influence on Afghan politics. They should take a page from their quiet cooperation in 2001, when they supported a conference of Afghan leaders in Bonn, Germany, that prepared Afghanistan for its transition to a constitution and elected government.

Once in office, Afghanistan’s next president will face myriad problems, not least that the Afghan economy will shrink as American funding for the war ends. Meanwhile, the most important task will remain keeping the Taliban at bay. If Afghan forces are not up to the job, Afghanistan will need a strong president with American and regional backing all the more. His job will be to negotiate a reconciliation with the Taliban. Which raises the question of how his disparate neighbors might find common ground to help. They should, because chaos in Afghanistan would threaten all of them.