MOGADISHU, Somalia — In a stealthy seaside assault in Somalia and in a raid in Libya’s capital, U.S. special forces on Saturday struck out against Islamic extremists who have carried out terrorist attacks in East Africa, snatching a Libyan al-Qaida leader allegedly involved in the bombings of U.S. embassies 15 years ago but aborting a mission to capture a terrorist suspect linked to last month’s Nairobi shopping mall attack after a fierce firefight.

A U.S. Navy SEAL team swam ashore near a town in southern Somalia before militants of the al-Qaida-linked terrorist group al-Shabab rose for dawn prayers, U.S. and Somali officials told The Associated Press. The raid on a house in the town of Barawe targeted a specific al-Qaida suspect related to the mall attack, but the operation did not get its target, one current and one former U.S. military official told AP.

Both officials spoke on condition of anonymity because they were not authorized to discuss the raid publicly.

In Washington, Pentagon spokesman George Little confirmed that U.S. military personnel had been involved in a counterterrorism operation against a known al-Shabab terrorist in Somalia, but did not provide details.

U.S. officials said there were no U.S. casualties in either the Somali or Libyan operation.

The Somali raid was carried out by members of SEAL Team Six, the same unit that killed al-Qaida leader Osama bin Laden in his Pakistan hideout in 2011, another senior U.S. military official said, speaking on condition of anonymity because the official was not authorized to speak publicly.

But this time, SEAL Team Six members encountered fiercer resistance than expected so after a 15-20 minute firefight, the unit leader decided to abort the mission and they swam away, the official said. SEAL Team Six has responsibility for counterterrorism activities in the Horn of Africa.

Within hours of the Somalia attack, the U.S. Army’s Delta Force carried out a raid in Libya’s capital, Tripoli, to seize a Libyan al-Qaida leader wanted for the 1998 bombings of the U.S. Embassies in Kenya and Tanzania that killed more than 220 people, the military official said. Delta Force carries out counterterrorism operations in North Africa.

The Pentagon identified the captured al-Qaida leader as Nazih Abdul-Hamed al-Ruqai, known by his alias Anas al-Libi, who has been on the FBI’s most wanted terrorists list since it was introduced shortly after the Sept. 11, 2001 attacks.

Al-Libi “is currently lawfully detained by the U.S. military in a secure location outside of Libya,” Pentagon spokesman Little said.

Saturday’s raid in Somalia occurred 20 years after the famous “Black Hawk Down” battle in Mogadishu in which a mission to capture Somali warlords in the capital went awry after militiamen shot down two U.S. helicopters. Eighteen 18 U.S. soldiers were killed in the battle, and it marked the beginning of the end of that U.S. military mission to bring stability to the Horn of Africa nation. Since then, U.S. military intervention has been limited to missile attacks and lightning operations by special forces.

A resident of Barawe — a seaside town 240 kilometers (150 miles) south of Mogadishu — said by telephone that heavy gunfire woke up residents before dawn prayers.

The U.S. forces attacked a two-story beachside house in Barawe where foreign fighters lived, battling their way inside, said an al-Shabab fighter who gave his name as Abu Mohamed and who said he had visited the scene. Al-Shabab has a formal alliance with al-Qaida, and hundreds of men from the U.S., Britain and Middle Eastern countries fight alongside Somali members of al-Shabab.

A separate U.S. official described the action in Barawe as a capture operation against a high-value target. The official said U.S. forces engaged al-Shabab militants and sought to avoid civilian casualties. The U.S. forces disengaged after inflicting some casualties on fighters, said the official, who was not authorized to speak by name and insisted on anonymity.

The leader of al-Shabab, Mukhtar Abu Zubeyr, also known as Ahmed Godane, claimed responsibility for the attack on the upscale mall in Nairobi, Kenya, a four-day terrorist siege that began on Sept. 21 and killed at least 67 people. A Somali intelligence official said the al-Shabab leader was the target of Saturday’s raid.

An al-Shabab official, Sheikh Abdiaziz Abu Musab, said in an audio message that the raid failed to achieve its goals.

Al-Shabab and al-Qaida have flourished in Somalia for years. Some of the plotters of the 1998 bombings of U.S. embassies in Kenya and Tanzania hid out there.

Barawe has seen Navy SEALs before. In September 2009 a daylight commando raid in Barawe killed six people, including Saleh Ali Saleh Nabhan, one of the most-wanted al-Qaida operatives in the region and an alleged plotter in the 1998 embassy bombings.

The Libyan al-Qaida leader also wanted for the bombings, al-Libi, is believed to have returned to Libya during the 2011 civil war that led to the ouster and killing of Libyan dictator Moammar Gadhafi.

His brother, Nabih, said al-Libi was parking outside his house early Saturday after dawn prayers when a convoy of three vehicles encircled his car. Armed gunmen smashed the car’s window and seized al-Libi’s gun before grabbing him and taking him away. The brother said al-Libi’s wife saw the kidnapping from her window and described the abductors as foreign-looking armed “commandos.”

Al-Libi, who was believed to be a computer specialist for al-Qaida, is on the FBI’s most-wanted list with a $5 million bounty on his head. He was indicted by a federal court in the Southern District of New York, for his alleged role in the bombings of the U.S. Embassies in Dar es Salaam, Tanzania, and Nairobi, Kenya, on August 7, 1998.

Libyan officials did not return calls seeking comment on al-Libi’s abduction.

In Somalia, a resident of Barawe who gave his name as Mohamed Bile said militants closed down the town in the hours after the assault, and that all traffic and movements have been restricted. Militants were carrying out house-to-house searches, likely to find evidence that a spy had given intelligence to a foreign power used to launch the attack, he said.

“We woke up to find al-Shabab fighters had sealed off the area and their hospital is also inaccessible,” Bile told The Associated Press by phone. “The town is in a tense mood.”

Al-Shabab later posted pictures on the Internet of what it said was U.S. military gear left behind in the raid. Two former U.S. military officers identified the gear as the kind U.S. troops carry. Pictures showed items including bullets, an ammunition magazine, a military GPS device and a smoke and flash-bang grenade used to clear rooms. The officials could not confirm if those items had come from the raid.

In Kenya, military spokesman Maj. Emmanuel Chirchir on Saturday gave the names of four fighters implicated in the Westgate Mall attack as Abu Baara al-Sudani, Omar Nabhan, Khattab al-Kene and Umayr, names that were first broadcast by a local Kenyan television station.

Matt Bryden, the former head of the U.N. Monitoring Group on Somalia and Eritrea, said via email that al-Kene and Umayr are known members of al-Hijra, the Kenyan arm of al-Shabab. He added that Nabhan may be a relative of Saleh Ali Saleh Nabhan, the target of the 2009 Navy SEALs raid in Barawe.

The identities of the four men from the mall attack came as a Nairobi station obtained and broadcast the closed circuit television footage from Westgate. The footage shows four attackers calmly walking through a storeroom inside the complex, holding machine guns. One of the men’s pant legs appears to be stained with blood, though he is not limping. It is unclear if the blood is his, or that of his victims’.

Government statements shortly after the four-day siege began on Sept. 21 indicated between 10 to 15 attackers were involved, but indications since then are that fewer attackers took part, though the footage may not show all of the assailants.