KABUL, Afghanistan -- About 40 U.S. commandos rushed into a compound in central Yemen to make a second attempt to rescue American journalist Luke Somers on Friday, but the special operators “lost the element of surprise” and Somers and another hostage appeared to be shot and killed by their captors before they could be rescued, defense officials said.

The failed mission was the second in recent weeks aimed at rescuing Somers, who was kidnapped in Sanaa, the capital, more than a year ago.

For President Barack Obama, it’s a grim reminder of how even the best, most highly-skilled military force can’t always succeed as well as it did during the famed Osama bin Laden raid in 2011 or even the successful rescue of the American ship captain from Somali pirates in 2009.

“This was difficult terrain to get to and a well-defended compound,” a defense official told reporters traveling with Defense Secretary Chuck Hagel. The official noted that the members of al-Qaeda in the Arabian Peninsula, or AQAP, the organization holding Somers, were likely “on edge, were clearly more alert” because of the first attempt to rescue Somers last month. A second rescue attempt would have been that much harder to pull off.

And there would have been less time to plan this mission, which was was moved up when intelligence sources indicated that AQAP, which had threatened to kill Somers by Saturday, might kill him even sooner. A video posted online this past week showed Somers, a freelance photographer, asking for help because he thought he would be killed.

With little to lose, the mission planners asked for the approval to conduct the mission. First Hagel and then Obama approved it mid-morning on Friday. The U.S. operation was done in coordination with Yemeni officials, defense officials said.

Hours later, the commandos landed in CV-22 Ospreys at the compound sometime Friday evening in an area known as Shabwah Governate in central Yemen. The commandos jumped out of the planes and ran about 100 meters to where they knew Somers was being held. Mission planners suspected there might be a second hostage with Somers, but they couldn’t be sure who it was.

Hagel, who left for Afghanistan from Washington, D.C. about noon on Friday, monitored the mission via classified emails aboard his military jet as he flew to South Asia, while officials in Washington watched in real time.

The “most difficult part of the mission,” said a defense official, lay in the first 5 or 10 minutes after the commandos landed and a firefight broke out. The special forces were only on the ground for about another 20 minutes before rescuing both Somers and the other hostage, South African Pierre Korki.

But it was too late. Members of the AQAP holding the men had appeared to have shot both as the commandos approached.

“When the element of surprise was lost, we believe that is when they were murdered,” said a defense official. “They were shot nearly immediately.”

One hostage died on the USS Makin Island, a U.S. naval ship waiting in the Gulf, and the other one died on the way. Defense officials were not clear if Somers died on the ship or on the airplane, but other media reports said he was the one who died on the Makin. More than five terrorists from the group were killed, but none captured, the defense official said. There were no injuries of American military personnel.