Nek Muhammad knew he was being followed.

On a hot day in June 2004, the Pashtun tribesman was lounging inside a mud compound in South Waziristan, speaking by satellite phone to one of the many reporters who regularly interviewed him on how he had fought and humbled Pakistan’s army in the country’s western mountains. He asked one of his followers about the strange, metallic bird hovering above him.

Less than 24 hours later, a missile tore through the compound, severing Mr. Muhammad’s left leg and killing him and several others, including two boys, ages 10 and 16. A Pakistani military spokesman was quick to claim responsibility for the attack, saying that Pakistani forces had fired at the compound.

That was a lie.

Mr. Muhammad and his followers had been killed by the C.I.A., the first time it had deployed a Predator drone in Pakistan to carry out a “targeted killing.” The target was not a top operative of Al Qaeda, but a Pakistani ally of the Taliban who led a tribal rebellion and was marked by Pakistan as an enemy of the state. In a secret deal, the C.I.A. had agreed to kill him in exchange for access to airspace it had long sought so it could use drones to hunt down its own enemies.

That back-room bargain, described in detail for the first time in interviews with more than a dozen officials in Pakistan and the United States, is critical to understanding the origins of a covert drone war that began under the Bush administration, was embraced and expanded by President Obama, and is now the subject of fierce debate. The deal, a month after a blistering internal report about abuses in the C.I.A.’s network of secret prisons, paved the way for the C.I.A. to change its focus from capturing terrorists to killing them, and helped transform an agency that began as a cold war espionage service into a paramilitary organization.