Just when you thought the world was dangerous enough, another crisis between nuclear weapons-armed India and Pakistan is brewing, and now al Qaeda is adding fuel to the fire by calling for jihad in the subcontinent.

Tensions have been growing all summer long, even though, ironically, things began on a positive high note: In June, newly elected Prime Minister Narendra Modi, who swept into power on a landslide, invited his Pakistan counterpart, Prime Minister Nawaz Sharif, to his inauguration.

Behind this unprecedented gesture, however, darker forces were planning a different sort of event. A squad of heavily armed terrorists attacked the Indian consulate in Herat, Afghanistan, right on the eve of the inauguration. They planned to take Indian diplomats hostage and then execute them as Modi was took office. Fortunately the Indian security guards at the consulate killed all the attackers.

The U.S. State Department publicly blamed Lashkar-e-Tayyiba, the group which attacked Mumbai in 2008. LeT is very close to the Pakistani military’s Inter Services Intelligence Directorate, or ISI. LeT would not have taken such a highly provocative action without at least some advance nod from the Pakistani spies in the ISI and the generals who command them. LeT’s leader, Hafeez Saeed, lives openly in Pakistan, frequently appears on television denouncing the United States, and is the darling of the ISI.

If there is another LeT attack like the one in Mumbai or the one in Herat, it will provoke the most serious crisis in years between India and Pakistan, and the more that can be done by the United States and other to prevent such a disaster the better. But it won’t be easy.

On Wednesday, to complicate the situation further, al Qaeda released a new videotape of its leader, Ayman Zawahiri, announcing the creation of an al Qaeda franchise in India. Zawahiri made the tape in his hideout in Pakistan, no doubt, and many Indians suspect the ISI is helping to protect him. Zawahiri has longstanding links to LeT and to Saeed. The 55-minute video is Zawahiri’s first this year and threatens jihadist attacks across India.

The domestic politics of Pakistan are central to this drama, and to this threat.

One of the goals of the Herat operation was to discredit Sharif, who has no control over the ISI or the Pakistani army. Since he was elected in his own landslide victory last year, the army has become increasingly unhappy with Sharif. They are very upset that he has put the former army dictator Pervez Musharraf on trial for treason and did not just let him leave the country quietly. Musharraf ousted Sharif in a coup in 1999, and while the army doesn’t care that much for Musharraf, it does not like the judicial system holding a general accountable for coups. For them that sets a bad precedent.

The army also was unhappy with Sharif’s reluctance to take on Pakistan’s own militant extremists, the Pakistan Taliban. Sharif wanted to talk to the Taliban; the army, for once, wanted to fight. Sharif ultimately gave in.

Meanwhile, violence has surged along the line of control in Kashmir, the province disputed by India and Pakistan since 1947 and the cause of several wars. This week the Indian army discovered a tunnel built under the line to infiltrate terrorists into Kashmir. Routine diplomatic talks between India and Pakistan have been suspended because Modi called them off when Pakistani diplomats met with Kashmiri leaders, a practice previously tolerated by New Delhi. Sharif had been urging deescalating the Indo-Pakistan rivalry and cutting back on the arms race, positions the army hardliners find threatening.

Sharif has been under siege—literally—in his office in Islamabad for the last couple of weeks, surrounded by an angry mob led by Pakistan’s famous photogenic cricket star and politician Imran Khan. Allied with a Canadian-Pakistani Islamic preacher, Khan has called for Sharif to resign. His movement has little nationwide popular support and there have been no demonstrations in other Pakistani cities backing his call, but it has kept Sharif preoccupied for weeks. Khan’s critics say he is being manipulated by the ISI to try to bring down Sharif or at least to neuter him. The army and the ISI were effective in neutering Sharif’s predecessor, Asif Zardari. In fact, that was a key goal achieved by the Mumbai attack in 2008. They want to neutralize Sharif by any means possible.

In short, the Pakistani army and its ISI spies are once again playing with fire—with India, the LeT and Kashmir—in order to secure domestic gains against their civilian leaders. Sharif is a weak prime minister today, just as he was the last two times he held that position in the 1990s, but he is the elected leader of the country. He should be allowed to finish his time in office.

The U.S. should step up intelligence cooperation with India to prevent and deter attacks such as the ones in Mumbai and Herat. Even if a terrorist action cannot be foiled, the more information exchanged about Pakistani ISI involvement with LeT, the more likely the U.S. will have credibility with New Delhi if a crisis does occur.

The United States should also consider a unilateral step if another attack occurs, threatening to place Pakistan on the State Department list of states sponsoring terrorism. America would treat Pakistan as a pariah like North Korea. It certainly meets the criteria and has for decades. The first Bush administration seriously considered this measure in 1992, although such a step obviously would have immense consequences for U.S.-Pakistan relations.

A more limited option would be to target specific sanctions against individual Pakistani officials involved in supporting terrorism, like members of ISI’s “S” branch that handles liaison with LeT, the Haqqani network and others. A targeted sanctions move against specific Pakistani military officials would send a strong deterrent message to the Pakistani army and could be a warning shot before putting Pakistan on the list of terror patrons.

Finally there should be contingency planning between Washington and New Delhi about managing a future Indo-Pakistan crisis like the Mumbai crisis. This would be intended to create dialogue, not creat a platform to gang up on Pakistan. But in any case it would be prudent to plan for the worst.