FOR YEARS, THE agonizing search for Osama bin Laden kept coming up empty. Then last July, Pakistanis working for the Central Intelligence Agency drove up behind a white Suzuki navigating the bustling streets near Peshawar, Pakistan, and wrote down the car’s license plate. The man in the car was bin Laden’s most trusted courier, and over the next month CIA operatives would track him throughout central Pakistan. Ultimately, he led them to a sprawling compound at the end of a long dirt road and surrounded by tall security fences in a wealthy hamlet 35 miles from the Pakistani capital.

On a moonless night eight months later, 79 American commandos in four helicopters descended on the compound, officials said. Shots rang out. A helicopter stalled and would not take off. Pakistani authorities, kept in the dark by their allies in Washington, scrambled forces as the American commandos rushed to finish their mission and leave before a confrontation. Of the five dead, one was a tall, bearded man with a bloodied face and a bullet in his head. A member of the Navy SEALs snapped his picture with a camera and uploaded it to analysts who fed it into a facial-recognition program.

And just like that, history’s most expansive, expensive, and exasperating manhunt was over.

ON SUNDAY AFTERNOON, as the helicopters raced over Pakistani territory, the president and his advisers gathered in the Situation Room of the White House to monitor the operation as it unfolded. Much of the time was spent in silence. Obama looked “stone-faced,” one aide said. Vice President Joe Biden fingered his rosary beads. “The minutes passed like days,” recalled John Brennan, the White House counterterrorism chief.

The code name for bin Laden was “Geronimo.” The president and his advisers watched Leon Panetta, the CIA director, on a video screen, narrating from his agency’s headquarters across the Potomac River what was happening in faraway Pakistan.

“They’ve reached the target,” he said. Minutes passed.

“We have a visual on Geronimo,” he said.

A few minutes later: “Geronimo EKIA.” Enemy Killed in Action. There was silence in the Situation Room.

Finally, the president spoke up.

“We got him.”

The raid was the culmination of years of painstaking intelligence work, including the interrogation of CIA detainees in secret prisons in eastern Europe, where sometimes what was not said was as useful as what was. Intelligence agencies eavesdropped on telephone calls and e-mails of the courier’s Arab family in a Persian Gulf state and pored over satellite images of the compound in Abbottabad.

Last July, Pakistani agents working for the CIA spotted the courier again, driving his vehicle near Peshawar. When, after weeks of surveillance, he drove to the sprawling compound in Abbottabad, American intelligence operatives felt they were on to something big, perhaps even bin Laden himself. It was hardly the spartan cave in the mountains that many had envisioned as his hiding place. Rather, it was a three-story house ringed by 12-foot-high concrete walls, topped with barbed wire and protected by two security fences. He was, said Brennan, the White House official, “hiding in plain sight.”

Back in Washington, Panetta met with Obama and his most senior national security aides, including Biden, Secretary of State Hillary Clinton, and Defense Secretary Robert Gates. Panetta spoke at length about bin Laden and his presumed hiding place.

“It was electric,” said an administration official who’d attended the meeting. “For so long, we’d been trying to get a handle on this guy. And all of a sudden, it was like, wow, there he is.”

What followed was weeks of tense meetings between Panetta and his subordinates about what to do next. While Panetta advocated an aggressive strategy to confirm bin Laden’s presence, some CIA clandestine officers worried that the most promising lead in years might be blown if bodyguards suspected the compound was being watched and spirited the Qaida leader out of the area.

For weeks last fall, spy satellites took detailed photographs, and the National Security Agency worked to scoop up any communications coming from the house. It wasn’t easy: The compound had neither a phone line nor Internet access. Those inside were so concerned about security that they burned their trash rather than put it on the street for collection.

In February, Panetta called Vice Adm. William McRaven, commander of the Pentagon’s Joint Special Operations Command, to CIA headquarters in Langley, Va., to begin planning a military strike. McRaven spent weeks working with the CIA on the operation, and came up with three options: a helicopter assault using American commandos, a strike with B-2 bombers that would obliterate the compound, or a joint raid with Pakistani intelligence operatives.

On March 14, Panetta took the options to the White House. The CIA had been taking satellite photos, establishing the habits of people at the compound. Evidence was mounting that bin Laden was there.

On March 22, the president asked his advisers their opinions on the options. Gates was skeptical about a helicopter assault, calling it risky, and instructed military officials to look into aerial bombardment using smart bombs. But a few days later, the officials returned with the news that it would take some 32 bombs of 2,000 pounds each. And how could the American officials be certain that they had killed bin Laden?

“It would have created a giant crater, and it wouldn’t have given us a body,” said one American intelligence official.

A helicopter assault emerged as the favored option. The Navy SEALs team that would hit the ground began holding dry runs at training facilities on both American coasts, which were made up to resemble the compound. But they were not told who their target might be until later.

Last Thursday, the day after the president released his long-form birth certificate—such “silliness,” he told reporters, was distracting the country from more important things—Obama met again with his top national security officials.

Panetta told the group that the CIA had “red-teamed” the case—shared their intelligence with other analysts who weren’t involved to see if they agreed that bin Laden was probably in Abbottabad. They did. It was time to decide.

Around the table, the group went over and over the negative scenarios. There were long periods of silence, one aide said. And then, finally, Obama spoke: “I’m not going to tell you what my decision is now—I’m going to go back and think about it some more.” But he added, “I’m going to make a decision soon.”

Sixteen hours later, he had made up his mind. Early the next morning, four top aides were summoned to the White House Diplomatic Room. Before they could brief the president, he cut them off. “It’s a go,” he said. The earliest the operation could take place was Saturday, but officials cautioned that cloud cover in the area meant that Sunday was much more likely.

The next day, Obama took a break from rehearsing for the White House Correspondents Dinner that night to call McRaven, to wish him luck. On Sunday, White House officials canceled all West Wing tours so unsuspecting tourists wouldn’t accidentally run into all the high-level national security officials holed up in the Situation Room monitoring the feeds they were getting from Panetta. A staffer went to Costco and came back with a mix of provisions—turkey pita wraps, cold shrimp, potato chips, soda.

At 2:05 p.m., Panetta sketched out the operation to the group for a final time. Within an hour, the CIA director began his narration, via video from Langley. “They’ve crossed into Pakistan,” he said.

THE COMMANDO TEAM had raced into the Pakistani night from a base in Jalalabad, just across the border in Afghanistan. It was just past midnight on Monday morning, and the Americans were counting on the element of surprise. As the first of the helicopters swooped in at low altitudes, neighbors heard a loud blast and gunshots. A woman who lives two miles away said she thought it was a terrorist attack on a Pakistani military installation. Her husband said no one had any clue bin Laden was hiding in the quiet, affluent area. “It’s the closest you can be to Britain,” he said of their neighborhood.

The SEAL team stormed into the compound—the raid awakened the group inside, one American intelligence official said—and a firefight broke out. One man held an unidentified woman living there as a shield while firing at the Americans. Both were killed. Two more men died as well, and two women were wounded. American authorities later determined that one of the slain men was bin Laden’s son, Hamza, and the other two were the courier and his brother.

The commandos found an unarmed bin Laden on the third floor, wearing the local loose-fitting tunic and pants known as a shalwar kameez. Officials said he resisted before he was shot above the left eye near the end of the 40-minute raid.

American officials insisted they would have taken bin Laden into custody if he did not resist, although they considered that likelihood remote. “If we had the opportunity to take bin Laden alive, if he didn’t present any threat, the individuals involved were able and prepared to do that,” Brennan said.

One of bin Laden’s wives identified his body at the scene, American officials said. A picture taken by a SEAL commando and processed through facial-recognition software suggested a 95 percent certainty that it was bin Laden. Later, DNA tests comparing samples with relatives found a 99.9 percent match.

But the Americans faced other problems. One of their helicopters stalled and could not take off. Rather than let it fall into the wrong hands, the commandos moved the women and children to a secure area and blew up the malfunctioning helicopter. By that point, though, the Pakistani military was scrambling forces in response to the incursion into Pakistani territory. “They had no idea about who might have been on there,” Brennan said.

As they took off at 1:10 a.m. local time, taking a trove of documents and computer hard drives from the house, the Americans left behind the women and children. A Pakistani official said nine children, from 2 to 12 years old, are now in Pakistani custody.

The Obama administration had already determined it would follow Islamic tradition of burial within 24 hours to avoid offending devout Muslims, yet concluded bin Laden would have to be buried at sea, since no country would be willing to take the body. Moreover, they did not want to create a shrine for his followers.

So the Qaida leader’s body was washed and placed in a white sheet in keeping with tradition. On the aircraft carrier Carl Vinson, it was placed in a weighted bag as an officer read prepared religious remarks.

The body then was placed on a prepared flat board and eased into the sea. Only a small group of people watching from one of the large elevator platforms that move aircraft up to the flight deck were witness to the end of America’s most wanted fugitive.

By Mark Mazzetti, Helene Cooper, and Peter Baker. Reporting contributed by Elisabeth Bumiller, Charlie Savage, and Steven Lee Myers from Washington; Adam Ellick from New York; and Ismail Khan from Peshawar, Pakistan. Copyright 2011 by The New York Times Co.