IN THEIR different ways, both Pakistan's sober-suited diplomats and its turbaned, bearded terrorists have this week reminded the world that their country remains indispensable to a settlement in Afghanistan. In protest at the killing in November of 24 Pakistani soldiers by NATO and Afghan forces, the diplomats boycotted a conference in Bonn at which 90 countries gathered to discuss Afghanistan's future. The next day, on the festival of Ashura, especially holy for Shia Muslims, some 60 died in apparently co-ordinated terrorist attacks in three Afghan cities. A Pakistan-based extremist organisation claimed responsibility.

Pakistan's absence meant that the Bonn conference offered little reassurance about Afghanistan's stability after 2014, the year when America and its NATO allies intend to complete handing over security to Afghan forces. The Ashura attacks raised the nightmarish prospect that the country might fall prey to one of the few curses it has been largely spared in the past decade: sectarian bloodletting between the Sunni majority and the Shias.

Many in Afghanistan and in NATO will see the two events as related: terrorist attacks as both payback for the Pakistani soldiers' deaths and a reinforcement of the diplomatic message. Senior American officials have been ever more vocal in denouncing the links between Pakistan's spies, the Inter-Services Intelligence agency (ISI) and the terrorists. In September the previous chairman of the Joint Chiefs of Staff, Admiral Mike Mullen, called one group, the Haqqani network, a “veritable arm” of the ISI. Pakistan of course denies any such links.

American diplomats, although convinced that the ISI dabbles in terrorism, think Admiral Mullen overstated the case. The latest attacks have not been claimed by either the Haqqani network or the Afghan Taliban, whose leadership is believed to be based in the Pakistani city of Quetta. Indeed, the Afghan Taliban, mostly Sunnis from Afghanistan's largest ethnic group, the Pushtuns, have condemned them—understandably, since not to do so would alienate minorities and undermine their political ambitions. Instead, the attacks have been claimed by an offshoot of Lashkar-e-Jhangvi (LeJ), a banned group with links to al-Qaeda and, of late, a tactical ally of the “Pakistani Taliban”, who unlike their Afghan namesakes are at war with the Pakistani state. LeJ was implicated in an attack on army headquarters in Rawalpindi in 2009. It may be many bad things, but it is not an arm of the ISI.

So, if elements of the ISI had a hand in this week's atrocities, the Pakistani government can plausibly deny it. But its message of Pakistan's centrality to an Afghan settlement is strengthened, whether or not a gruesome act of revenge was intended. And revenge is a popular demand in Pakistan after the killing of those 24 soldiers. NATO's presence in Afghanistan was already deeply resented in Pakistan as an American war that costs Pakistani lives. Pakistan's support for it now has even fewer advocates at home. Commentators have seen the deaths as just the latest and most serious in a series of American stabs in the back.

One came in January when a CIA contractor killed two people in murky circumstances in a Lahore street. Next there was the secret raid in May by American navy SEALs to kill Osama bin Laden on Pakistani soil. America was outraged that bin Laden was there. Pakistan was outraged its authorities were not warned of the raid, let alone asked for permission. Now its soldiers, politicians and pundits alike are saying: enough is enough.

Pakistan has also tried to demonstrate how important it is to America in more practical ways than just its diplomatic sulk. It has closed two border posts through which large quantities of NATO supplies have passed. It has cut off intelligence co-operation, which, for all its shortcomings, had led to a steady stream of arrests and killings of American targets. And it has ordered America to quit a base from which it is believed to have launched drone raids on terrorists in Pakistan—another cause of deep local resentment.

The government is clearly exasperated that its anger seems almost to have gone unnoticed in Washington. It took Barack Obama a week to call his Pakistani counterpart, Asif Ali Zardari, to offer “condolences” for the soldiers' killing. Pakistanis catching the talk shows on American news channels might think Americans believe it is their soldiers who were killed by Pakistanis, so sour is the attitude toward Pakistan. This week two senior Republican senators, John McCain and Lindsey Graham, issued a statement calling for a review of American aid to Pakistan, arguing that “the United States has been incredibly patient with Pakistan. And we have been so despite certain undeniable and deeply disturbing facts.”

Allies like these

It must still be likely that, after a decent interval, the allies will patch it up. After all, both have an interest in a stable Afghanistan, and Pakistan needs American aid. But in both countries long election seasons have already begun, making it harder for politicians to offer concessions to an unpopular partner. Pakistan's government is beset by legal threats and beholden to its overweening army. When it was reported this week that Mr Zardari was in Dubai for medical treatment for a heart complaint, many speculated that this was a prelude to his resignation. His government may be unable to accept a renewal of ties unless America guarantees that its strategic concerns will be met in an Afghan settlement.

Those concerns demand the installation in Afghanistan of a government with which it feels comfortable, and strict limits on Indian influence there. But, to pursue these goals, Pakistan, not for the first time, is finding itself playing a very dangerous game. If it is no longer offering the border crossings, drone base and intelligence help, Pakistan's role in America's war effort becomes more that of a spoiler. And if you're not with us, as the previous American president put it succinctly…

Economist.com/blogs/banyan