These days, it's easy to assume the worst about Afghanistan's interminable election crisis.

Both presidential candidates believe they won the election, and neither wants to back down. And on some levels, it's hard to blame then. The preliminary run-off results placed Ashraf Ghani far ahead, and his election staff -- who tout the heavy campaigning they undertook before the second round of voting, particularly in Pashtun areas -- expects him (as most observers do) to eventually be declared the winner.

Meanwhile, Abdullah Abdullah insists the vote was marred by massive fraud. For him, this is déjà vu: Back in 2009, he lost to Hamid Karzai in an election widely believed to be rife with fraud. He doesn't want the same thing to happen to him in 2014.

In July, after Abdullah vowed to reject the runoff results (a vow he reiterated on Sept 8), disturbing reports surfaced that Abdullah's supporters were planning to take over select government facilities. U.S. Secretary of State John Kerry quickly arrived in Kabul to help broker a deal, which led to the full audit of the run-off election that wrapped up earlier this month.

That deal, however, also called for a power-sharing arrangement--and yet talks over a unity government are currently deadlocked.

Such troubling realities -- and the implication that the crisis is bound to continue if not deepen, with a new government not nearly on the horizon -- make for a sad state of affairs.

They also provide fodder for a multitude of nightmare scenarios: A leaderless Afghanistan, including its fragile armed forces, will fracture along ethnic lines; it will be convulsed by widespread violence, and possibly even plunged into civil war; it will experience some form of coup, orchestrated by the declared loser or even by the Karzai administration. And, if the crisis manages to drag on for several more months, Afghans will watch helplessly as every international troop leaves the country -- a zero option implemented two years early, because no president is in place to sign the bilateral security agreement (BSA) needed to authorize a post-2014 residual force.

Such doomsday talk makes for sexy headlines and engrossing dinner party debate. Yet this doesn't mean Afghanistan is doomed. On the contrary, there is still hope for a positive outcome to the current impasse.

First, Ghani and Abdullah are fully aware of the catastrophic economic costs of a crisis that goes unresolved. Washington and its allies could reduce or even end assistance to Afghanistan -- a deeply troubling prospect for a country where international donor assistance is a lifeline for a floundering economy (about half of Afghanistan's budget comes from foreign assistance). Indeed, Kerry may well have invoked the threat of an aid cutoff to compel the two candidates to agree to the audit deal back in July. The specter of an aid cutoff should be sufficient motivation for them to reach a power-sharing deal, even if it takes time and is done grudgingly.

Second, Ghani and Abdullah are firmly committed to inking a BSA -- as is the entire mainstream Afghan political class, with the seemingly solitary exception of Karzai. The compelling reasons for one -- from the critical training it would provide to Afghan security forces to the psychological boost it would provide to the country on the whole -- are well-documented. There is still ample time for concluding an agreement; President Barack Obama waited until the second half of October before deciding to pull all U.S. troops from Iraq in 2011. And yet until Afghanistan has a new president in place, a BSA will remain aspirational. Additionally, if the weeks continue to pass without a new government in place, the possibility increases that the Pentagon would not have enough time to plan for the continued deployment of all of the originally envisioned 9,800 troops next year -- and, consequently, that any eventual BSA would result in a smaller number of residual U.S. personnel.

Third, the longer the crisis drags out, the more Afghanistan's other crises deepen -- a trend that neither Ghani nor Abdullah wants to continue. The economy has been in free fall for quite some time. Meanwhile, the Taliban insurgency is enjoying a second wind and launching new offensives. Clearly, the Taliban is testing Afghan troops to see how well they can fight without combat assistance from international forces. Afghan troops will likely face even greater tests in the coming weeks and months: Anti-government protests in neighboring Pakistan have strengthened that country's army,  increasing the likelihood that the Pakistani security establishment will intensify support for -- and consequently further empower -- traditional proxies such as the Afghan Taliban, Haqqani network, and other groups that terrorize Afghanistan. Afghan forces need more help from Kabul -- and yet there is no government to decide how, and in what form, to provide it. 

To be sure, all three of the above factors assume, perhaps naively, that Ghani and Abdullah will actually set aside their personal political ambitions for the sake of the national interest. Yet here, there is reason for optimism. Amid all the heated rhetoric, Abdullah has called on his supporters to avoid violence.  And, on Sept. 8, when he spoke vaguely about "consulting the Afghan people" on next steps, he was probably implying that the door remains open for a deal. Ghani is similarly conciliatory, insisting on Sept.10 that "we need to have an inclusive government."

Nonetheless, the challenge of bringing the two sparring sides together is immense. This was made crystal clear on Sept. 9, when Karzai issued a call for national unity at a ceremony for Ahmad Shah Massoud, the revered anti-Taliban freedom fighter killed by al-Qaeda two days before the 9/11 attacks. Shortly after Karzai's speech, a speaker who happened to be a Ghani partisan took the stage. Abdullah supporters booed him mercilessly, causing such a major disruption that the event had to end prematurely. In essence, a call for unity was drowned out by the din of a deeply divided crowd.

No one ever said it will be easy to craft a happy ending to this tale -- but it's still quite possible. The U.S. government can increase the chances of success by staying in close touch with Ghani and Abdullah; given the urgency of the situation, Washington no longer enjoys the luxury of opting to stay out of an internal political matter. Admittedly, with the White House consumed by the conflict in Ukraine, the global Ebola epidemic, and above all the threat from the Islamic State, robust levels of engagement may not be possible. Still, there are encouraging signs: Obama and Kerry have been in touch with both candidates in recent days. Obama would be wise to dispatch Kerry to Kabul after the top U.S. diplomat wraps up his current trip in the Middle East.

It is also critical that Afghanistan's election commission not announce the final results of the runoff until there is agreement on a power-sharing deal. The commission's decision to release the preliminary results so quickly made sense for reasons of transparency, but it also ratcheted up tensions and contaminated the environment for negotiations. The commission should avoid making the same mistake this time around (unfortunately, as of this writing, election officials continued to insist they will release the results regardless of whether a deal is in place or not).   

Ultimately, Afghanistan -- as well as Washington and the broader international community -- must hope that Ghani and Abdullah heed the plea made on Sept. 8 by Ahmad Wali Massoud, the younger brother of Ahmad Shah Massoud (and a less divisive figure than Karzai, whose similar plea fell on disastrously deaf ears one day later). Massoud urged the two candidates to keep the interests of Afghans in mind, and "to put all political tensions aside and reach agreements on creating an inclusive government."

It's a tall order. Still, despite the doomsday talk, it's by no means an impossible one.

The opinions expressed here are solely those of the author.

The original article was published in Foreign Policy.