WASHINGTON — Intelligence officers made an important discovery this spring after monitoring Ayman al-Zawahri, the chief of Al Qaeda, to Kabul, Afghanistan: He appreciated to learn alone on the balcony of his protected home early within the morning.

Analysts seek for that sort of pattern-of-life intelligence, any behavior the C.I.A. can exploit. In al-Zawahri’s case, his lengthy balcony visits gave the company a possibility for a transparent missile shot that might keep away from collateral harm.

The hunt for al-Zawahri, one of many world’s most wished terrorists, stretches again to earlier than the Sept. 11 assaults. The C.I.A. continued to seek for him as he rose to the highest of Al Qaeda after the loss of life of Osama bin Laden and after the Taliban takeover of Afghanistan final 12 months. And one misstep, the recruitment of a double agent, led to one of many bloodiest days within the company’s historical past.

Quickly after america left Kabul, the C.I.A. sharpened its efforts to search out al-Zawahri, satisfied he would attempt to return to Afghanistan. Senior officers had instructed the White Home they’d have the ability to preserve and construct informant networks contained in the nation from afar, and that america wouldn’t be blind to terrorism threats there. For the company, discovering al-Zawahri could be a key take a look at of that assertion.

This text relies on interviews with present and former American and different officers, impartial analysts who’ve studied the decades-long hunt and others briefed on the occasions main as much as the weekend strike. Most spoke on the situation of anonymity due to the delicate intelligence used to search out al-Zawahri.

For years al-Zawahri was regarded as hiding within the border space of Pakistan, the place many Qaeda and Taliban leaders took refuge after the U.S. invasion of Afghanistan in late 2001. He was wished in reference to the 1998 embassy bombings in Tanzania and Kenya, and the C.I.A. had tracked a community of people that intelligence officers thought supported him.

The examination of that community intensified with the U.S. exit from Afghanistan final 12 months and a perception amongst some intelligence officers that senior leaders of Al Qaeda could be tempted to return.

The hunch proved proper. The company discovered that al-Zawahri’s household had returned to a protected home in Kabul. Although the household tried to make sure they weren’t being watched and to maintain al-Zawahri’s location secret, intelligence companies quickly discovered he too had returned to Afghanistan.

“There was a renewed effort to determine the place he was,” stated Mick Mulroy, a former C.I.A. officer. “The one good factor that may have come out of withdrawing from Afghanistan is that sure high-level terrorist figures would then assume it’s protected for them to be there.”

The protected home was owned by an aide to senior officers within the Haqqani community, a battle-hardened and violent wing of the Taliban authorities, and it was in an space managed by the group. Senior Taliban leaders often met on the home, however American officers have no idea what number of knew that the Haqqanis have been hiding al-Zawahri.

If some senior Taliban officers didn’t know that the Haqqanis had allowed al-Zawahri to return, his killing may drive a wedge between the teams, impartial analysts and others briefed on the occasions stated.

It isn’t clear why Al-Zawahri moved again to Afghanistan. He had lengthy made recruiting and promotional movies, and it could have been simpler to provide them in Kabul. He additionally could have had higher entry to medical therapy.

It doesn’t matter what the explanation, his ties to leaders of the Haqqani community led U.S. intelligence officers to the protected home.

“The Haqqanis have a really lengthy relationship with Al Qaeda going again to the mujahedeen days,” stated Dan Hoffman, a former C.I.A. officer. “They supply Al Qaeda with numerous tactical help that they want.”

As soon as the protected home was positioned, the C.I.A. adopted the playbook it wrote in the course of the hunt for Bin Laden. The company constructed a mannequin of the positioning and sought to study every part about it.

Analysts finally recognized a determine who lingered on the balcony studying, however by no means left the home, as al-Zawahri.

U.S. officers rapidly determined to focus on him, however the location of the home posed issues. It was within the Sherpur neighborhood of Kabul, an city space of intently spaced homes. A missile armed with a big explosive may harm close by houses. And any form of incursion by Particular Operation forces could be prohibitively harmful, limiting the choices for the U.S. authorities to conduct a strike.

The seek for al-Zawahri carried enormous significance for the company. After the U.S. invasion of Afghanistan, the C.I.A. base in Khost Province turned residence to a focusing on group devoted to monitoring each Bin Laden and al-Zawahri. It was one of many leads developed by the C.I.A. to trace al-Zawahri that proved disastrous for the company’s officers at that base, Camp Chapman.

C.I.A. officers recruited Humam Khalil Abu Mulal al-Balawi, a Jordanian physician and propagandist for Al Qaeda, who they hoped would cause them to al-Zawahri. He supplied American officers with details about al-Zawahri’s well being, convincing them his intelligence was actual. However he was in reality a double agent, and on Dec. 30, 2009, he confirmed up at Camp Chapman with a suicide vest. When it exploded, seven brokers have been killed.

For a lot of, the Khost assault intensified efforts to search out al-Zawahri. “To honor their legacy, you keep it up with the mission,” Mr. Hoffman stated.

In 2012 and 2013, the C.I.A. centered the hunt on Pakistan’s North Waziristan area. C.I.A. analysts have been assured that they had discovered the small village the place al-Zawahri was hiding. However intelligence companies couldn’t discover his home within the city of a couple of dozen compounds, making a raid or drone strike unimaginable.

Nonetheless, the U.S. hunt compelled al-Zawahri to stay within the tribal areas of Pakistan, probably limiting the effectiveness of his management inside Al Qaeda.

“Anytime something associated to Bin Laden or Zawahri hit the intel channels, everybody stopped to pitch in and assist,” stated Lisa Maddox, a former C.I.A. analyst. “It was the C.I.A.’s promise to the general public: to carry them to justice.”

On April 1, high intelligence officers briefed nationwide safety officers on the White Home in regards to the protected home and the way that they had tracked al-Zawahri. After the assembly, the C.I.A. and different intelligence companies labored to study extra about what they known as al-Zawahri’s sample of life.

One key perception was that he was by no means seen leaving the home and solely appeared to get contemporary air by standing on a balcony on an higher ground. He remained on the balcony for prolonged durations, which gave the C.I.A. an excellent probability to focus on him.

Al-Zawahri continued to work on the protected home, producing movies to be distributed to the Qaeda community.

A senior administration official, who spoke on the situation of anonymity to debate the delicate selections resulting in the strike, stated the intelligence introduced to the White Home had been repeatedly vetted, together with by a group of impartial analysts tasked with figuring out everybody who was staying on the protected home.

As choices for a strike have been developed, intelligence officers examined what sort of missile could possibly be fired at al-Zawahri with out inflicting main harm to the protected home or the neighborhood round it. They in the end selected a type of Hellfire missile designed to kill a single individual.

William J. Burns, the C.I.A. director, and different intelligence officers briefed President Biden on July 1, this time with the mannequin of the protected home, the senior official stated.

At that assembly, Mr. Biden requested about the potential for collateral harm, prodding Mr. Burns to take him by means of the steps of how officers had discovered al-Zawahri and confirmed his info, and their plans to kill him.

Mr. Biden ordered a sequence of study to attempt to predict the impression of the strike on the Taliban, the area and American efforts to maneuver Afghans to america, the senior official stated. The president additionally requested in regards to the attainable dangers to Mark R. Frerichs, an American hostage held by the Haqqanis.

In June and July, officers met a number of occasions within the State of affairs Room to debate the intelligence and look at the potential ramifications.

The C.I.A. plans known as for it to make use of its personal drones. As a result of it was utilizing its personal belongings, few Pentagon officers have been introduced into the planning for the strike, and lots of senior navy officers discovered about it solely shortly earlier than the White Home announcement, an official stated.

On July 25, Mr. Biden, glad with the plan, approved the C.I.A. to conduct the airstrike when the chance introduced itself. Sunday morning in Kabul, it did. A drone flown by the C.I.A. discovered al-Zawahri on his balcony. The company operatives fired the missile, ending a greater than two-decade-long hunt.

Thomas Gibbons-Neff, Adam Goldman and Michael Crowley contributed reporting.