After Davis was picked up by the Lahore police, the embassy became a house divided by more than mere geography. Just days before the shootings, the C.I.A. sent a new station chief to Islamabad. Old-school and stubborn, the new chief did not come to Pakistan to be friendly with the I.S.I. Instead, he wanted to recruit more Pakistani agents to work for the C.I.A. under the I.S.I.’s nose, expand electronic surveillance of I.S.I. offices and share little information with Pakistani intelligence officers.

That hard-nosed attitude inevitably put him at odds with the American ambassador in Islamabad, Cameron Munter. A bookish career diplomat with a Ph.D. in history, Munter had ascended the ranks of the State Department’s bureaucracy and accepted several postings in Iraq before ultimately taking over the American mission in Islamabad, in late 2010. The job was considered one of the State Department’s most important and difficult assignments, and Munter had the burden of following Anne W. Patterson, an aggressive diplomat who, in the three years before Munter arrived, cultivated close ties to officials in the Bush and Obama administrations and won praise from the C.I.A. for her unflinching support for drone strikes in the tribal areas.

Munter saw some value to the drone program but was skeptical about the long-term benefits. Arriving in Islamabad at a time when relations between the United States and Pakistan were quickly deteriorating, Munter wondered whether the pace of the drone war might be undercutting relations with an important ally for the quick fix of killing midlevel terrorists. He would learn soon enough that his views about the drone program ultimately mattered little. In the Obama administration, when it came to questions about war and peace in Pakistan, it was what the C.I.A. believed that really counted.

With Davis sitting in prison, Munter argued that it was essential to go immediately to the head of the I.S.I. at the time, Lt. Gen. Ahmad Shuja Pasha, to cut a deal. The U.S. would admit that Davis was working for the C.I.A., and Davis would quietly be spirited out of the country, never to return again. But the C.I.A. objected. Davis had been spying on a militant group with extensive ties to the I.S.I., and the C.I.A. didn’t want to own up to it. Top C.I.A. officials worried that appealing for mercy from the I.S.I. might doom Davis. He could be killed in prison before the Obama administration could pressure Islamabad to release him on the grounds that he was a foreign diplomat with immunity from local laws — even those prohibiting murder. On the day of Davis’s arrest, the C.I.A. station chief told Munter that a decision had been made to stonewall the Pakistanis. Don’t cut a deal, he warned, adding, Pakistan is the enemy.

The strategy meant that American officials, from top to bottom, had to dissemble both in public and in private about what exactly Davis had been doing in the country. On Feb. 15, more than two weeks after the shootings, President Obama offered his first comments about the Davis affair. The matter was simple, Obama said in a news conference: Davis, “our diplomat in Pakistan,” should be immediately released under the “very simple principle” of diplomatic immunity. “If our diplomats are in another country,” said the president, “then they are not subject to that country’s local prosecution.”

Calling Davis a “diplomat” was, technically, accurate. He had been admitted into Pakistan on a diplomatic passport. But there was a dispute about whether his work in the Lahore Consulate, as opposed to the American Embassy in Islamabad, gave him full diplomatic immunity under the Vienna Convention on Diplomatic Relations. And after the shootings in Lahore, the Pakistanis were not exactly receptive to debating the finer points of international law. As they saw it, Davis was an American spy who had not been declared to the I.S.I. and whom C.I.A. officials still would not admit they controlled. General Pasha, the I.S.I. chief, spoke privately by phone and in person with Leon Panetta, then the director of the C.I.A., to get more information about the matter. He suspected that Davis was a C.I.A. employee and suggested to Panetta that the two spy agencies handle the matter quietly. Meeting with Panetta, he posed a direct question.

Was Davis working for the C.I.A.? Pasha asked. No, he’s not one of ours, Panetta replied. Panetta went on to say that the matter was out of his hands, and that the issue was being handled inside State Department channels. Pasha was furious, and he decided to leave Davis’s fate in the hands of the judges in Lahore. The United States had just lost its chance, he told others, to quickly end the dispute.