THOUGH America's relations with Pakistan grow ever more wretched, it remains hard to imagine either side daring to break them off. Military types, diplomats, analysts and politicians in Islamabad describe a mood more poisonous than at any time for a generation. Links between the intelligence agencies, the core of bilateral relations for six decades, are worst of all, notably since America caught Osama bin Laden hiding amid Pakistan's apron strings. Pakistan felt humiliated too by the way the al-Qaeda leader was killed.

Yet the ties still bind, amid fears of far worse. Last month, America's departing chief of staff, Mike Mullen, said Pakistan's army spies ran the Haqqani network, a militant outfit that has killed American men in Afghanistan and attacked the embassy in Kabul in September. The chatter in Pakistan was of frenzied preparation for military confrontation.

Many Pakistanis seemed jubilant at the idea, with polls suggesting over 80% of them are hostile to their ally, and chat shows competing to pour scorn on America as the root of all evil. Instead relations have been patched up. Last week Barack Obama said mildly that the outside world must “constantly evaluate” Pakistan's behaviour. In what may signal a conciliation of sorts, a new CIA chief has been installed in Islamabad, the third in a year after Pakistani spies outed his predecessors.

American policy is contradictory. On the one side are defence types, eager to fight jihadists and angry at Pakistani meddling in southern and eastern Afghanistan. On the other side are diplomats, anxious about losing tabs on Pakistani nukes or having to do without Pakistani assistance in stopping terror attacks in the West. Many also fear the spreading failure of the Pakistani state (see article). A senior American official in Islamabad starkly describes how the relationship seemed lost last month, with “huge numbers of people trying not to let it go over the edge”.

For the moment ties persist, though they are loosened. America has suspended military aid, supposedly worth hundreds of millions of dollars (Pakistanis say Americans inflate the figures). It has not paid its agreed dues to Pakistan's army for several months, nor have its trainers returned. America is also readier than before to back things that Pakistan despises, such as India's blossoming relations with Hamid Karzai, the Afghan president, who last week swept through Delhi to laud India's growing role as a donor.

Pakistan's army has responded by giving a little ground. It still refuses America's call for a war on militants in the border area of North Waziristan—“it's bad strategy to ignite everything at once” sniffs a gloomy Pakistani official—but it has, apparently, nudged Haqqani leaders from their hiding places over the border into Afghanistan. At the same time Pakistanis complain of impossible American demands over jihadists: they say Mr Obama's strategy of “fight and talk” in Afghanistan requires Pakistan's army to handle insurgent fighters by killing, capturing and bringing them into negotiations all at the same time.

Afghanistan, where the two countries fumble and fail to accommodate each other, will remain the crux of Pakistan's relations with America. Pakistan's leaders long derided what they saw as America's vain “transformative” struggle to make Afghanistan modern, democratic and united—perhaps they also feared a similar push to refashion the role of the army in Pakistan. The head of Pakistan's armed forces, General Ashfaq Kayani, in particular, is said to dismiss America's understanding of the fractured country next door as naive and simplistic, a doomed effort to make Afghanistan into something it is not.

But as America's ambitions there have shrunk to little more than extracting its soldiers fast and leaving behind a minimally stable territory that is not dominated by Pushtuns, concerns in Pakistan have grown anew. It now fears being abandoned, losing aid and relevance, and becoming encircled by forces allied with its old foe, India. Several commentators in Islamabad suggest that, sooner than have a united neighbour that is pro-India, Pakistan would prefer more war and division in Afghanistan—“let Afghanistan cook its own goose” says an ex-general.

A crunch could come in the next few months, as foreigners gather for a pair of summits on Afghanistan, first in Istanbul in November, then in Bonn in December. What should have been a chance to back domestic peace talks (which have not happened) could instead be a moment for recrimination, with Pakistanis to take the blame. Worse yet for Pakistan would be if its ill-starred performance as an ally becomes a prominent issue in Mr Obama's presidential re-election campaign. Afghanistan is sure to dominate a NATO summit to be held in Chicago in May.

Afghanistan may, or may not, recede in importance after 2014, when America is due to cut the number of soldiers it has in the region. Yet even without the thorn of Afghanistan, a list of divisive, unattended issues infects Pakistan's relations with America. On their own they would be more than enough to shake relations between most countries.

Pakistan is a known proliferator, and is more hostile than almost any other country to America's global efforts to cut nuclear arsenals and prevent the spread of weapons of mass destruction. America is fast expanding its economic and military ties with Pakistan's great rival, India. And Pakistan's domestic rule would set most American diplomats' hair on end—venal civilian leaders; army men hankering for the next coup and having pesky journalists killed off; Islamists who shoot opponents for being liberal. With a friend like Pakistan, who needs enemies?