That close collaboration has eroded over the years. In 2010, the identity of the C.I.A.’s station chief, Jonathan Bank, appeared in the Pakistani press in what American officials suspected was a leak planted by the I.S.I. Bank’s replacement, Mark Kelton, arrived at an inopportune time: a day after he showed up, two Pakistani men died in an altercation in Lahore with a C.I.A. contractor, Raymond Davis, who claimed that the men had tried to rob him. And Kelton was still there when, in May, 2011, Navy seals helicoptered into Pakistan, stormed Osama bin Laden’s compound, and killed the Al Qaeda leader. At one point, the I.S.I. chief at the time, Ahmed Shuja Pasha, told the U.S. Ambassador, Cameron Munter, how Kelton, who could be dour, reminded him of a “walking cadaver.” Not long after, Kelton fell ill. He suspected that he had been poisoned.

Eventually, the C.I.A. stopped notifying the I.S.I. of drone strikes in advance. Pakistani officials, in turn, exaggerated the number of civilians killed in the American strikes, according to several former officials. The C.I.A. has been exacting in its efforts to avoid civilian casualties, officials told me. For instance, in May, 2013, according to two former intelligence officials, agency drones spotted Wali-ur-Rehman, the deputy emir of the Pakistani Taliban, on the roof of a compound where, in the summer months, it was cooler than sleeping inside. There was a clear shot from the drone circling overheard, but analysts at C.I.A. headquarters were wary that a direct strike would bring the whole house down, and kill numerous women and children inside. After studying the house for hours, they decided that they could fire the missile from an oblique angle, killing Rehman and his associates on the roof, while saving those below. The Predator dropped into a low orbit and fired several missiles, which skimmed the roof and killed Rehman. The officials said that no civilians died.