Mr. Somers had been part of a group of freelance journalists who covered the aftermath of Yemen’s 2011 uprising and had stayed on, working as a freelance editor at English-language publications and as a photojournalist. He was kidnapped in September 2013 while walking on a street in Sana, Yemen’s capital. Shortly before his death, Mr. Somers’s family released a video in which they pleaded with his captors to release him, while insisting that they had no prior knowledge of the first rescue attempt.

On Saturday, Mr. Somers’s sister, Lucy Somers, told The Associated Press that F.B.I. agents had notified the family of her brother’s death.

“We ask that all of Luke’s family members be allowed to mourn in peace,” she said.

In the village where the rescue attempt took place, in the southern province of Shabwah, a tribal leader, Tarek al-Daghari al-Awlaki, said the American commandos had raided four houses, killing at least two militants but also eight civilians. He said that one of the civilians killed was a 70-year-old man.

“The shooting caused panic,” Mr. Daghari said. “Nine of the dead are from my tribe.” He added that villagers had spent the rest of Saturday burying the dead and collecting spent bullet casings.

American officials said they acted while facing a perilous deadline and a tiny window of opportunity. Mr. Somers’s captors said in a video statement released Wednesday that they would kill him by Saturday unless unspecified demands were met. The ultimatum for Mr. Somers appeared to be largely a response to the first raid, on Nov. 25, an operation led by United States Special Operations commandos on a cave near Yemen’s border with Saudi Arabia. The commandos freed eight other hostages and killed seven militants, but found no sign of Mr. Somers, who apparently had been moved in the days before the operation.

By Saturday, though, the United States had tracked him to a walled compound in the village in southern Yemen. American intelligence, including spy satellites, surveillance drones and eavesdropping technology, had pinpointed the location of Mr. Somers and one other Western hostage inside the compound, according to a senior military official who provided an account of the operation. The official spoke on the condition of anonymity to discuss classified operations.

Image Pierre Korkie Credit... Gift of Givers, via Agence France-Presse — Getty Images

America’s Special Operations forces have played a central role in global combat missions since the attacks of Sept. 11, 2001, the most notable being the raid into Pakistan in 2011 that killed Osama bin Laden. But the challenges of distance, weather, equipment failure, pinpoint intelligence — and unpredictable actions by the adversary — are ever-present.

A raid in July by Special Operations forces against an Islamic State safe house in Syria also failed to free American hostages, who apparently had been relocated in advance of the mission.

In the case of the raid Saturday, the intelligence on Mr. Somers’s location was accurate. It seems likely that the deadline set by the militant captors to kill him on Saturday set the clock on carrying out the mission.

It remained to be seen whether the killings represented a larger shift in the tactics of Al Qaeda, which has largely turned away from executing hostages in recent years in favor of negotiating ransoms — a contrast to the frequent executions carried out by the Islamic State in Iraq and Syria. When they have faced military raids, Al Qaeda militants have executed hostages.

The operation on Saturday began at about 1 a.m. The SEAL Team 6 commandos, joined by a small number of Yemeni counterterrorism troops, swept toward the village aboard V-22 Osprey tilt-rotor aircraft under cover of darkness early Saturday local time. They landed several hundred yards from the compound in an effort to remain undetected.

Their effort faced steep odds. The compound, which was located in a remote, hilly area, surrounded by scrub, was guarded by about half a dozen gunmen, already jittery about a possible repeat of the previous rescue attempt. And the approach to the compound was sufficiently difficult that the commandos had virtually no element of surprise, which they typically plan for and rely on. The commandos were detected when they were less than 100 yards from the compound. It was not clear what alerted the militants.