Pakistani men attend a rally with a banner that shows Indian Prime Minister Narendra Modi's face crossed out.Muhammad Sajjad / AP

The standoff between India and Pakistan would be hard enough to resolve if the two countries did not have nuclear weapons. That’s before you factor in a jingoistic media scene, the rapid spread of rumors and disinformation on messaging and social-media apps, and the fact that India’s nationalist prime minister is heading into parliamentary elections.

The result: the worst military crisis between the countries in nearly two decades. Stepping back from the brink now will require political courage in New Delhi and reciprocity in Islamabad.

This latest dispute has several causes. First, there’s the historical, territorial, and fundamental national-identity issues that remain unresolved between them. Then there’s the Pakistani military-intelligence complex’s use of non-state actors against India over a span of several years. And finally, there’s the proximal cause of today’s crisis—that after years of absorbing terrorist attacks conceived and planned on Pakistani soil, India chose to say enough was enough.

The Pakistan-based group Jaish-e-Mohammed has claimed responsibility for an attack two weeks ago that struck a convoy of Indian paramilitary personnel, killing 40 Indians. New Delhi promised retaliation, and delivered with air strikes against what it said was a terrorist camp near the Pakistani town of Balakot—the first such move involving the use of conventional airpower by one nuclear-armed state against the territory of another. The Indian foreign ministry claimed the strikes were “preemptive” and the targets “non-military.” The choice of target, similarly, was based on what the Indian foreign secretary said was credible intelligence.

Above all, the Indian side emphasized the status of Jaish-e-Mohammed as a repeat offender. India had endured a 2001 attack on its parliament planned by the group and a January 2016 assault on an airbase—both without retaliating, even as the 2001 incident brought both sides to the brink of war. Other attacks, in July 2015 and September 2016, had been carried out by Pakistan-based militants, with the latter prompting India to take limited military action in the form of what it called “surgical strikes.” In November 2008, most infamously, terrorists belonging to Pakistan-based Lashkar-e-Taiba staged an attack on civilians in Mumbai.

Given this history, India’s latest strike was not, in the country’s view, an act of war, but one of self-defense. India’s broad practice of strategic restraint since the 2002 crisis had, in a way, allowed it to accumulate years of credibility on the international stage that was, in effect, “spent” this week with its strike at Balakot.

Nevertheless, the ingress into Pakistani territory for the first time since the 1971 war between the two countries left the Pakistani military embarrassed. Swift retaliation was promised—and Pakistan delivered with strikes of its own across the Line of Control, the de facto border. Indian jets pursued the Pakistani fighters that had conducted the strikes, suffering losses in the process. One Indian pilot was captured alive and remains in Pakistani custody.

The ingredients are now present for an all-out conflagration. Headlines the world over have emphasized the countries’ status as nuclear powers, underscoring the stakes. But there’s a choice now over how this might end—and it is largely India’s to make. Pakistan’s response has reset the onus for retaliation on New Delhi, and finding a way out that’s acceptable to both countries will not be easy.

India’s action is without precedent since the nuclear age began in South Asia. True, the two countries fought a war in 1999 under the nuclear overhang, but that conflict took place within politically proscribed limits, with then–Indian Prime Minister Atal Behari Vajpayee having specifically instructed the military to not cross the Line of Control at any cost.

While New Delhi’s latest decision to retaliate was based on national security, its leadership had to concern itself with more mundane questions of political expediency too. India is just weeks away from a general election that will once again see the world’s largest exercise in democracy take place. Prime Minister Narendra Modi and his nationally dominant Bharatiya Janata Party could have faced electoral trouble if they mismanaged the response.

And though much about the current crisis has its roots in familiar issues, what is different this time for the two countries rattling sabers, after their respective nuclear breakouts, is the proliferation of social media and the growth of nationalistic television-news networks—primarily in India. The Indian government is culpable too for egging on the sort of public opinion that now corners it ahead of the election; the 2016 “surgical strikes” were immortalized in a Bollywood film recently.

Unlike in previous cases, a bout of American shuttle diplomacy may not be an option, either; the U.S. State Department’s South Asia desk remains manned largely by acting officials, and the United States has no permanent ambassador to Pakistan. Other powers such as China, Russia, Saudi Arabia, and Iran lack the credibility to serve the “honest broker” role that Washington was once able to play adeptly in South Asia.  Pakistan’s envoy in Washington has called for American involvement, but New Delhi may favor bilateral resolution.

India’s best course of action would be to focus its diplomatic energy on a long-standing campaign to isolate Pakistan until it systematically changes its ways on the use of proxy groups, and its military energy on denying Jaish-e-Mohammed and Lashkar-e-Taiba access to their targets.

Yet for Modi, an avowed nationalist, the safer course of action in the short term appears to be erring on the side of strength and resolve. This may have been the underpinning of why India took the sort of action it did, instead of retaliating in a less escalatory manner—such as into Pakistan-administered Kashmir, a disputed territory. Since the 1971 war, the use of air forces between the two countries has been seen as uniquely escalatory. Even as India steered clear of Pakistani military facilities, the fact that Pakistan’s territory had been struck immediately raised the stakes.

In Pakistan, the strike left some military strategists wondering what the country’s nuclear weapons are for anyway. For Islamabad, the central role of its nuclear arsenal is to prevent even the thought in the heads of India’s political leadership that another war like the 1971 war between the two countries could ever be fought. That defeat was a moment of profound trauma in Pakistan, as the country was cleaved in two and the newly independent nation of Bangladesh was born. Pakistan accelerated its nuclear efforts and, following its nuclear breakout shortly after India’s in 1998, its military thought that it had closed the space in which the two countries might exchange blows.

In recent years, Pakistan has largely secured its second strike and developed battlefield nuclear weapons, designed to be flushed out from storage early in a crisis with India to create what the nuclear deterrence theorist Thomas Schelling once famously termed the “threat that leaves something to chance.” In effect, Pakistan’s objective was to establish deterrence at the conventional level by seeking to establish in the minds of India’s political leaders that any sufficiently large military action inside Pakistan’s territory could result in the probable—if not likely—use of nuclear weapons. Schelling employed a metaphor of two individuals astride the edge of a cliff, tied to each other by the ankle. Pakistan had to convince India of its willingness to fall off that cliff.

The impression that Tuesday’s strikes leave on Pakistan’s military establishment is that deterrence failed—even if nuclear red lines weren’t crossed and nuclear weapons were never going to deter a single bout of preemptive airstrikes. Still, Pakistan’s own retaliation serves to reestablish deterrence, by demonstrating that it has conventional options of its own short of nuclear weapons.

The crisis may yet peter out, and the two sides have publicly said they do not wish to escalate their dispute further. Khan’s decision to unilaterally release the captured Indian pilot as a gesture of goodwill speaks to precisely the sort of courage necessary on both sides to stand down. In remarks after his country’s strike, Pakistan’s leader acknowledged to India “the grief that you have suffered,” taking on a conciliatory tone, and called for dialogue. Importantly, he offered a Schelling-esque argument to his counterpart in India. “I ask India, given the weapons capability on both sides, can we afford a miscalculation?” he said. “It will neither be in my control nor Modi’s.”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.