Last week, India sent warplanes into Pakistan for the first time in five decades. Indian officials said they had struck Jaish-e-Muhammad’s “biggest training camp” and killed a “very large number” of militants, although those claims have been called into doubt. Pakistan counterattacked, leading to a dogfight in which at least one Indian jet was shot down and a pilot was captured by the Pakistanis.

The situation could have easily escalated, given that the two countries have fought three wars over 70 years, maintain a near-constant state of military readiness along their border and have little formal government-to-government dialogue.

Adding to the volatility, India’s prime minister, Narendra Modi, is waging a tough re-election campaign in which he has used anti-Pakistan talk to fuel Hindu nationalism.

With Pakistan’s Army most likely shaken by the Indian raid and unwilling to slide into protracted conflict, Prime Minister Imran Khan returned the pilot to India, in what was seen as a good-will gesture, called for talks and promised an investigation into the bombing. Mr. Modi took the opportunity to back off further escalation.

The next confrontation might not end so calmly.

Pakistan has never seriously cracked down on militant groups that attack India and the Indian-controlled part of Kashmir. In recent days, Pakistani authorities said they detained 44 members of various armed groups, including a brother of Masood Azhar, the head of Jaish-e-Muhammad, and planned to seize assets of militants on the United Nations terrorist list. But Pakistan has rarely followed through on such promises.