The war of words between nuclear-armed India and Pakistan is a reminder that the ceasefire line dividing the Himalayan state of Kashmir remains, in the words of former US president Bill Clinton, “the most dangerous place in the world”. This month’s confrontation was sparked when a suicide bomber blew up a convoy of more than 40 Indian soldiers in India’s Kashmir, the deadliest terror strike in decades. Jaish-e-Mohammed (JeM), a terrorist group based in Pakistan, claimed responsibility for the attack. The Himalayan region of Kashmir is claimed by both India and Pakistan and the two fought three wars over it since it was split between them in 1947. Over the weekend both Delhi and Islamabad beat the drums of war across the roof of the world.

The greatest risk is a miscalculation by India or Pakistan. Delhi ought to resist the urge to respond militarily, not least because of the chance of escalation. Pakistan, for its part, ought to move decisively against terrorist groups which despite being banned operate with impunity on its soil. Both need to seek a way out of confrontation. There is a nonchalance, often about how a war between these historic rivals could be contained. Yet in 1999, when Indian forces were on the verge of routing Pakistani troops which had crossed the border and captured mountain peaks in the Kargil region, Islamabad began preparing its nuclear weapons for deployment. The world stood on the precipice of an all-out regional war which would have led not only to tens of millions of deaths but whose fallout would have crippled global agricultural supplies. Mr Clinton forced the Pakistani establishment to step away from the nuclear abyss.

The leadership in both India and Pakistan have to avoid escalating a foreign crisis that they cannot back down from. With general elections later this year, domestic politics will shape how India’s Narendra Modi will respond to the bombing. Mr Modi has ramped up the rhetoric in campaign rallies vowing to “take revenge for each and every drop of blood shed”. The 20-year-old suicide bomber was a Kashmiri, leading to awful reprisals against Kashmiri students in other parts of India. It is shameful that it took India’s supreme court to chastise the government before Mr Modi said Kashmiris should be kept safe. India’s prime minister must seek peace in restive Kashmir. His militaristic approach has pushed the state to the brink of disaster. Locking up political activists will not help, nor will remoulding Kashmir’s constitutional status to the disadvantage of locals.

Pakistan’s new prime minister, Imran Khan, is also playing to the domestic gallery by warning of his country’s retaliation. Islamabad says it has closed down JeM’s headquarters in its Punjab province, although Pakistan’s record of briefly cracking down on terror groups only to relax controls when the pressure eases is a not a good sign. The real power in Pakistan is the nation’s military and its officials tweeted that they are “fully prepared for a befitting response to any Indian aggression or misadventure”. It is dangerous to think nuclear-armed nations can engage in a tit-for-tat spiral. The Pakistani army has got used to the idea that its nuclear weapons can prevent Indian conventional military superiority from punishing its support of anti-India terror groups. But two years ago Indian forces did conduct cross-border raids after a JeM attack, though thankfully tensions abated. Every serious crisis now risks a potential nuclear exchange at the outset. Much more is needed to move the two nations away from a vicious circle that binds them.