This article was first published on Foreign Policy's .

The core feature of Afghan President Ashraf Ghani’s foreign policy since assuming office has been the reset of relations with Pakistan. Moving toward reconciliation with his neighbor was seen as the key to opening a peace process with the Afghan Taliban. It was also thought crucial to the president’s strategic vision to secure Afghanistan’s future through regional economic and political cooperation. Instead, Afghanistan and Pakistan are moving on a path that threatens to bring their relations down to a level not witnessed in more than a quarter century. If allowed to continue, the Afghan unity government and the Afghan state itself could be imperiled.

The downward spiral in relations follows from the shattering of three interrelated myths generally shared by the Kabul government and its American and European allies. The first myth described the Afghan conflict as inevitably ending in a political agreement to which members of the insurgency could ascribe. The second depicted an essentially nationalist Taliban as a cohesive and hierarchical movement. The third rested on the idea that decades of suspicion and distrust between Afghanistan and Pakistan could be overcome through farsighted, determined diplomacy. All three myths were flawed, yet they persisted because they were convenient fictions.

Faced with a seemingly intractable conflict allowing for no clear military outcome, Afghan leaders, together with a war-weary public and American and European officials, wanted to believe that a political accord could be reached with the Taliban to end the fighting. For the Afghan government’s military partners and benefactors, it offered a way to disengage from Afghanistan that could preserve most of the gains achieved since 2001. A grand deal with the Taliban that provided for meaningful power sharing was thought likely to be attractive to an exhausted enemy whose leaders had presumably concluded the impossibility of rapidly overrunning the country as they had in the 1990s. A popularly elected government, with an internationally backed 350,000-strong security force, was thought to convince the Taliban of its inability to capture Afghanistan’s major urban centers.

It was also necessary to see the Taliban’s Quetta Shura leadership as having sufficient authority to negotiate a broad peace agreement. Divisions known to exist within the organization were discounted because the movement ultimately maintained an allegiance to spiritual leader Mullah Omar, who, while not a hands-on commander, ultimately had the last word. Despite the Taliban’s known links to al Qaeda and Pakistan’s jihadist organizations, it was further useful to picture Taliban ambitions as more national than ideological and therefore likely to be satisfied with an agreement that basically preserved the Afghan constitution.

The third myth found it convenient to believe that a Pakistani military and civilian leadership, having come around to believing that Pakistan’s interests were best served by a stable united Afghanistan under Ashraf Ghani’s leadership, would also be willing to discard a strategy that relies on a surrogate Taliban force as a hedge against a fragmenting Afghanistan. It was also opportune to imagine that through personal diplomacy a self-confident Ghani would be able to persuade Pakistan to yield up the Taliban and also sell the idea of reconciliation with Pakistan to a deeply skeptical Afghan public.

The reigning myths then crashed. Almost eight months of progress in improving bilateral relations suddenly ended in May. The revelation that the intelligence services of Afghanistan and Pakistan had signed a secret agreement to work together against terrorists caused a firestorm of protest that caught Ghani and his advisors by surprise. He was immediately forced to backpedal. To placate public feelings, the president turned against Pakistan, demanding it implement a set of tough measures against the Taliban. Pakistan was then held accountable for a series of bombings in Kabul and elsewhere that began in June. And in July the announced death of Mullah Omar laid bare the deep factionalism in the Taliban and strengthened dissident groups, some of which have aligned with the recently emerged Islamic State, and all of them preferring jihad to peace.

Now Pakistani-Afghan reconciliation is on life support and the peace process moribund. In Mullah Mansour’s post-Omar efforts to consolidate his position as the Taliban’s unchallenged leader, he has renounced holding further negotiations. His naming of Sirajuddin Haqanni to the top leadership serves as a concession to those most opposed to talks. Meanwhile, Ghani has gone from pressing for Pakistan’s cooperation in facilitating peace talks to demanding the arrest of some of the very people with whom Afghanistan had hoped to negotiate. He has directly implicated Pakistan in Afghanistan’s civilian deaths, and his CEO Abdullah Abdullah boasts that Afghan security forces are capable of crossing the border to eliminate Taliban militants. Afghanistan’s acting defense minister claims that Pakistan has already entered into a declared war against Afghanistan.

Until now Pakistan has reacted to events with some restraint. It has refused to respond directly to Afghan allegations, and has called on Afghanistan to cease its anti-Pakistan propaganda. Pakistan has shown displeasure with the sharp criticism from Kabul by indefinitely 3,000 promised scholarships to Afghan students. But its leaders that they stand “shoulder to shoulder with [their] Afghan brethren” and have condemned the spate of deadly bombings. They have also insisted that Pakistan to facilitating a peace dialogue with the Taliban.

A serious rupture in relations will be damaging for both countries, more so for landlocked Afghanistan. One serious casualty could be a decision by Pakistan to impede bilateral trade and transit activities. A denial of access to the port of Karachi could have a particularly crippling effect on Afghanistan’s struggling economy for which expanding use of Iran’s port facilities can only partly compensate. Without Pakistan’s cooperation, Afghanistan’s hopes of providing a crossroad for integrated regional trade will fade along with budding plans for a transit gas pipeline from Turkmenistan. Afghanistan’s economy, along with its political stability, could also be put under severe pressure should Pakistan decide to send home most of its three million registered and unregistered Afghan refugees.

Tensions along the already volatile border of Pakistan and Afghanistan are bound to increase. The gains in military cooperation over recent months in confronting their respective insurgent groups will end, as will any prospect of eliminating either cross-border sanctuary. Afghan ties to India are likely to strengthen and with it a heightening of Pakistani long-established strategic fears of encirclement. The Afghan government could be expected to invite India to assume a larger role in its economy and security, including the possible introduction of military personnel. Suspicions that India is using Afghan soil in order to meddle in Balochistan are almost certain to grow. Intensifying nationalist feelings would benefit Pakistan’s militants anxious to assume greater involvement in Afghanistan and Kashmir, and rising feelings of nationalism in Afghanistan are bound to give new life to the provocative issue of Pashtunistan.

The deterioration in relations must be arrested before it goes any further. This will require that Ghani and Abdullah weigh carefully the consequences of alienating Pakistan. Pakistan can do more to restrain resident insurgents and rein in ISI cooperation with the insurgents, even if unwilling for now to relinquish its Taliban surrogates. Avoiding worsening of relations may require the two sides to seek mediation, perhaps from China. Both Afghanistan and Pakistan must recognize militant extremism as their chief enemy, and that neither country can be secure or expect to prosper without the other. Want it or not, their destinies remain bound together.