On Jan. 27, a trigger-happy C.I.A. contractor named Raymond Davis was stuck in Lahore traffic and shot dead two motorcyclists who approached him. A backup vehicle he summoned ran over and killed a bystander. The US spent heavily from its meagre stock of good will to persuade the Pakistanis to set Davis free pleading with a straight face that he was entitled to diplomatic immunity. On May 2, a US Navy Seals team caught Osama bin Laden in the military town Abbottabad and killed him. Before long, American officials were quoted questioning whether their Pakistani allies were just incompetent or actually complicit. (The Americans who deal with Pakistan believe that Pakistani army was genuinely surprised and embarrassed that Bin Laden was so close by, though the Americans fault the Pakistanis for not looking very hard.) In September, members of the Haqqani clan (a criminal syndicate and jihadi cult thats avowedly subservient to the Taliban leader Mullah Omar) marked the 10th anniversary of 9/11 with two theatrical attacks in Afghanistan. First a truck bomb injured 77 American soldiers in Wardak Province. Then militants rained rocket-propelled grenades on the US Embassy in Kabul, forcing our ambassador to spend 20 hours locked down in a bunker. A few days later the former Afghan president, Burhanuddin Rabbani, spread his arms to welcome an emissary from the Taliban to discuss the possibility of peace talks. As they embraced, the visitor detonated a bomb in his turban, killing himself, Rabbani and the talks. President Hamid Karzai of Afghanistan, without any evidence that American officials are aware of, accused Pakistan of masterminding the grotesque killing in order to scuttle peace talks it couldnt control. And two days after that, Adm. Mike Mullen, the outgoing chairman of the Joint Chiefs of Staff, took to Capitol Hill to suggest that Pakistani intelligence had blessed the truck bomb and embassy attack. His testimony came as a particular shock, because if the turbulent affair between the United States and Pakistan had a solid centre in recent years, it was the rapport between Mullen and his Pakistani counterpart, General Kayani. Over the four years from Kayanis promotion as chief of the army staff until Mullens retirement in September, scarcely a month went by when the two didnt meet. Mullen would often drop by Kayanis home at the military enclave in Rawalpindi, arriving for dinner and staying into the early morning, discussing the pressures of command. One time, Kayani took his American friend to the Himalayas for a flyby of the worlds second-highest peak, K2. On another occasion, Mullen hosted Kayani on the golf course at the Naval Academy. The two men seemed to have developed a genuine trust and respect for each other. But Mullens faith in an underlying common purpose was rattled by the truck bombing and the embassy attack. So over the objection of the State Department the admiral set out to demonstrate that he had no illusions. The Haqqani network acts as a veritable arm of Pakistans Inter-Services Intelligence agency, he declared. With ISI support, Haqqani operatives planned and conducted that truck-bomb attack as well as the assault on our embassy. Several officials with access to the intelligence told me that while the Haqqanis were implicated in both attacks, there was no evidence of direct ISI involvement. A Mullen aide said later that the admiral was referring to ISIs ongoing sponsorship of the Haqqanis and did not mean to say Pakistan authorised those specific attacks. No matter. In Pakistan, Mullens denunciation led to a ripple of alarm that US military hardliners were contemplating an invasion. The press had hysterics. Kayani made a show of putting the Pakistani Army on alert. The Pakistani rupee fell in value. In Washington, Mullens remarks captured and fed a vengeful mood and a rising sense of fatalism about Pakistan. Bruce O. Riedel, an influential former CIA officer who led a 2009 policy review for President Obama on Pakistan and Afghanistan, captured the prevailing sentiment in an Op-Ed in The Times, in which he called for a new policy of containment, meaning a more hostile relationship toward the army and intelligence services. I can see how this gets worse, Riedel told me. And I can see how this gets catastrophically worse. . . . I dont see how it gets a whole lot better. When Gen. David H. Petraeus took over the US militarys Central Command in 2008, he commissioned expert briefing papers on his new domain, which sprawled from Egypt, across the Persian Gulf, to Central Asia. The paper on Afghanistan and Pakistan began, according to an American who has read it, roughly this way: The United States has no vital national interests in Afghanistan. Our vital national interests are in Pakistan, notably the security of those nuclear weapons and the infiltration by Al Qaeda. The paper then went on for the remaining pages to discuss Afghanistan. Pakistan hardly got a mention. Thats typical, my source said. Pakistan tends to be an afterthought. The Pakistani version of modern history is one of American betrayal, going back at least to the Kennedy administrations arming of Pakistans archrival, India, in the wake of its 1962 border war with China. The most consequential feat of American opportunism came when we enlisted Pakistan to bedevil the Soviet occupiers of Afghanistan in the 1980s. The intelligence agencies of the US and Pakistan with help from Saudi Arabia created the perfect thorn in the Soviet underbelly: young Muslim freedom fighters, schooled in jihad at Pakistani madrassas, laden with American surface-to-air missiles and led by charismatic warriors who set aside tribal rivalries to war against foreign occupation. After the Soviets admitted defeat in 1989, the US mission accomplished pulled out, leaving Pakistan holding the bag: several million refugees, an Afghanistan torn by civil war and a population of jihadists who would find new targets for their American-supplied arms. In the ensuing struggle for control of Afghanistan, Pakistan eventually sided with the Taliban, who were dominated by the Pashtun tribe that populates the Pakistan-Afghanistan frontier. The rival Northern Alliance was run by Tajiks and Uzbeks and backed by India; and the one thing you can never underestimate is Pakistans obsession with bigger, richer, better-armed India. As long as Pakistan was our partner in tormenting the Soviet Union, the US winked at Pakistans nuclear-weapons programme. After all, India was developing a nuclear arsenal, and it was inevitable that Pakistan would follow suit. But after the Soviets retreated, Pakistan was ostracised under a Congressional antiproliferation measure called the Pressler Amendment, stripped of military aid (some of it budgeted to bring Pakistani officers to the US for exposure to American military values and discipline) and civilian assistance (most of it used to promote civil society and buy good will). Our relationship with Pakistan sometimes seems like a case study in unintended consequences. The spawning of the mujahadeen is, of course, Exhibit A. The Pressler Amendment is Exhibit B. And Exhibit C might be Americas protectionist tariffs on Pakistans most important export, textiles. For years, experts, including a series of American ambassadors in Islamabad, have said that the single best thing the US could do to pull Pakistan into the modern world is to ease trade barriers, as it has done with many other countries. Instead of sending foreign aid and hoping it trickles down, we could make it easier for Americans to buy Pakistani shirts, towels and denims, thus lifting an industry that is an incubator of the middle class and employs many women. Congress, answerable to domestic textile interests, has had none of it. Pakistan the afterthought was the theme very late one night when I visited the home of Pakistans finance minister, Abdul Hafeez Shaikh. After showing me his impressive art collection, Shaikh flopped on a sofa and ran through the roll call of American infidelity. He worked his way, decade by decade, to the war on terror. Now, he said, Pakistan is tasked by the Americans with simultaneously helping to kill terrorists and the newest twist using its influence to bring them to the bargaining table. Congress, meanwhile, angry about terrorist sanctuaries, is squeezing off much of the financial aid that is supposed to be the lubricant in our alliance. Pakistan was the cold-war friend, the Soviet-Afghan-war friend, the terror-war friend, the minister said. As soon as the wars ended, so did the assistance. The sense of being discarded is so recent. A Boston University-educated economist who made his money in private equity investing in other words, a cosmopolitan man Shaikh seemed slightly abashed by his own bitterness. Im not saying that this style of Pakistani thinking is analytically correct, he said. Im just telling you how people feel. He waved an arm toward his dining room, where he hung a Warhol of Muhammad Ali. Were just supposed to be like Ali take the beating for seven rounds from Foreman, he said. But this time the Pakistanis have wised up. We are playing the game, but we know you cant take these people at their word. With a timetable that has the United States out of Afghanistan, or mostly out, by the end of 2014, Pakistan has leverage it did not have when the war began. One day after 9/11, Richard Armitage, the deputy secretary of state, summoned the head of Pakistani intelligence for a talking to. We are asking all of our friends: Do they stand with us or against us? he said. The following day, Armitage handed over a list of seven demands, which included stopping Al Qaeda operations on the Pakistani border, giving American invaders access to Pakistani bases and airspace and breaking all ties with the Taliban regime. The Pakistanis believed from the beginning that Afghanistan had American quagmire written all over it. Moreover, what America had in mind for Afghanistan was antithetical to Pakistans self-interest. The only time period between 1947 and the American invasion of Afghanistan that Pakistanis have felt secure about Afghanistan is during the Taliban period, from 1996 to 2001, says Vali Nasr, an American scholar of the region who is listened to in both academia and government. Now the Bush administration would attempt to supplant the Taliban with a strong independent government in Kabul and a muscular military. Everything about this vision is dangerous to Pakistan, Nasr says. Pakistans military ruler at the time, Pervez Musharraf, saw the folly of defying an American ultimatum. He quickly agreed to the American demands and delivered on many of them. In practice, though, the accommodation with the Taliban was never fully curtailed. Pakistan knew Americas mission in Afghanistan would end, and it spread its bets. The Bush-Musharraf relationship, Vali Nasr says, was sort of a Hollywood suspension of disbelief. Musharraf was a convenient person who created a myth that we subscribed to basically that Pakistan was on the same page with us, it was an ally in the war on terror and it subscribed to our agenda for Afghanistan. But the longer the war in Afghanistan dragged on, the harder it was to sustain the illusion. In October, I took the highway west from Islamabad to Peshawar, headquarters of the Pakistan Army corps responsible for the frontier with Afghanistan. Over tea and cookies, Lt. Gen. Asif Yasin Malik, the three-star who commanded the frontier (he retired this month) talked about how the Afghan war looked from his side of the border. The official American version of the current situation in Afghanistan goes like this: By applying the counterinsurgency strategy that worked in Iraq and relying on a surge of troops and the increasingly sophisticated use of drones, the United States has been beating the insurgency into submission, while at the same time standing up an indigenous Afghan Army that could take over the mission. If only Pakistan would police its side of the border where the bad guys find safe haven, fresh recruits and financing wed be on track for an exit in 2014. The Pakistanis have a different narrative. First, a central government has never successfully ruled Afghanistan. Second, Karzai is an unreliable neighbour a reputation that has not been dispelled by his recent, manic declarations of brotherhood. And third, they believe that despite substantial investment by the United States, the Afghan Army and the police are a long way from being ready to hold the country. In other words, America is preparing to leave behind an Afghanistan that looks like incipient chaos to Pakistan. In Peshawar, General Malik talked with polite disdain about his neighbour to the west. His biggest fear one Im told Kayani stresses in every meeting with his American counterparts is the capability of the Afghan National Security Forces, an army of 170,000 and another 135,000 police, responsible for preventing Afghanistan from disintegrating back into failed-state status. If the US succeeds in creating such a potent fighting force, that makes Pakistanis nervous, because they see it (rightly) as potentially unfriendly and (probably wrongly) as a potential agent of Indian influence. The more likely and equally unsettling outcome, Pakistanis believe, is that the Afghan military immature, fractious and dependent on the US Treasury will disintegrate into heavily armed tribal claques and bandit syndicates. And America, as always, will be gone when hell breaks loose. General Malik studied on an exchange at Fort McNair, in Washington, DC, and has visited 23 American states. He likes to think he is not clueless about how things work in our country. Come 2015, which senator would be ready to vote $9 billion, or $7 billion, to be spent on this army? he asked. Even $5 billion a year. OK, maybe one year, maybe two years. But with the economy going downhill, how does the future afford this? Very challenging. American officials will tell you, not for attribution, that Maliks concerns are quite reasonable. So I asked the general if that was why his forces have not been more aggressive about mopping up terrorist sanctuaries along the border. Still hedging their bets? His answer was elaborate and not entirely facile.