The assault on Osama bin Laden — as quick and ruthless an operation as you would see in any spy movie — shows that the CIA and the military’s super-secret Joint Special Operations Command have combined to create what amounts to a highly effective killing machine.

The shorthand for these operations is “find, fix, finish.” The CIA and other intelligence agencies typically provide the first two, and the bin Laden attack shows that this process can take years of patient detective work. JSOC warriors then come in for the finish.

A reconstruction of how this operation was put together shows how the pieces of America’s counterterrorism policy fit together. It also illuminates one of the CIA’s biggest puzzles, which is whether it can work effectively with Pakistan’s Inter-Services Intelligence directorate. The answer seems to be “sometimes.”

The trail that led to bin Laden’s hideout in the town of Abbottabad, about 75 miles north of Islamabad, began between 2002 and 2004 with the CIA’s interrogation of al-Qaeda “high-value targets” at secret CIA sites overseas. Several detainees mentioned the “nom de guerre,” or nickname, of one of bin Laden’s couriers.

Some of the detainees who confirmed the courier’s nickname were subjected to “enhanced interrogation techniques,” the CIA’s formal name for what is now widely viewed as torture. This adds a moral ambiguity to a story that is otherwise one of triumphal retribution and justice.

The CIA spent years trying to figure out the courier’s identity. Using sources that U.S. officials won’t discuss, the agency finally discovered the courier’s real name in 2007, along with the important fact that he had a brother. In early 2009, a team from the agency’s counterterrorism center traced him to a compound in Abbottabad that he shared with the brother.

Pakistan was told little about the bin Laden manhunt, for fear that the information would leak. But a U.S. official said the Pakistanis offered some help. “They provided information that helped us identify where one of the brothers might be located,” this official said. He added: “They didn’t tell us he was in Abbottabad, but their information allowed us to track him there.”

Now the agency had a suspect location but no firm idea bin Laden was there. Surveillance confirmed that this was an unusual compound. The surrounding walls were up to 18 feet high, and even the balconies had seven-foot walls. And the compound maintained unusual security: It had no telephone or Internet service, and trash was regularly burned.

As the CIA continued its surveillance, analysts concluded that another family was secretly living in the compound, along with the two brothers. The number of family members and other details matched bin Laden’s likely family group. This crucial “circumstantial” evidence was briefed to President Obama last August, says a U.S. official.

This year, JSOC began preparing the “finish” operation, using members of Seal Team 6, its most elite counterterrorism unit. Obama was given a choice between bombing the compound or staging the raid. Obama opted for the latter, believing the United States needed to capture bin Laden’s body.

One of the mysteries is whether the Pakistani government knew all along who was hiding in Abbottabad. It is hardly remote territory: A Pakistani military college is two miles away. A senior U.S. official says the CIA has carefully examined this question but has “zero evidence” of Pakistani government knowledge of bin Laden’s location. That’s not quite the same as saying for certain that the Pakistanis didn’t know, and it allows the ISI and CIA to continue working as sometime partners.

CIA Director Leon Panetta, who directed the operation, told Pakistan nothing until the helicopters had left Abbottabad to return to Afghanistan. But U.S. officials describe the subsequent Pakistani reaction as helpful. Pakistani officials urged Obama to make his unusual late-night announcement so the Pakistani public would immediately know the U.S. had attacked bin Laden, not a Pakistani target. And Islamabad promised to try to mitigate Pakistani popular anger, which officials did by issuing a supportive statement Monday.

Does bin Laden’s demise mean the death of al-Qaeda? CIA analysts won’t go that far. But they have concluded that the operation “will accelerate its demise,” and that the battered organization is now at a “tipping point” that could lead to collapse.

The hidden trophy of Sunday’s raid: The JSOC team captured intelligence materials from the compound that might reveal the location of Ayman al-Zawahiri, the organization’s new commander. “That’s where we’re going next,” says one U.S. official involved in planning the operation.