US forces launched raids in Libya and Somalia on Saturday, capturing a top al-Qaida figure wanted for the 1998 US embassy bombings in Kenya and Tanzania, but failing to secure the target in Somalia, US officials said.

Senior al-Qaida figure Anas al-Liby was seized in the raid in Libya, but no militant was captured in the raid on the Somali town of Barawe, the officials said, speaking on condition of anonymity.

The Pentagon confirmed US military personnel had been involved in an operation against what it called "a known al-Shabaab terrorist" in Somalia, but gave no more details.

One US official, speaking to Reuters on condition of anonymity, said the al-Shabaab leader targeted in the operation was neither captured nor killed.

US officials did not identify the target. They said US forces, trying to avoid civilian casualties, disengaged after inflicting some al-Shabaab casualties. They said no US personnel were wounded or killed in the operation.

A US navy Seal team swam ashore near Barawe, southern Somalia, before dawn prayers, US and Somali officials told the Associated Press.

They approaching a two-storey beachfront property in small boats, reportedly supported by a helicopter and naval gunfire.

The 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 US military official said, speaking on condition of anonymity because the official was not authorised to speak publicly.

This time the Seal team members encountered fiercer resistance than expected, and 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 counter-terrorism activities in the Horn of Africa.

US navy commandos killed a senior al-Qaida member in the same town four years ago.

The New York Times quoted a US security official as saying that the target was believed to have been killed, but later accounts called that into question.

The New York Times quoted an unnamed US security official saying the raid was planned a week and a half ago and prompted by the attack on Nairobi's upmarket Westgate shopping mall two weeks ago in which at least 67 people were killed.

Ahmed Godane, the leader of al-Shabaab, said he was responsible for the four-day assault on the mall. Photograph: -/AFP/Getty Images

The paper also reported that a senior Somali government official said: "The attack was carried out by the American forces and the Somali government was pre-informed about the attack."

Claims by an al-Shabaab spokesman that the raid involved British and Turkish special forces and that a British commando had been killed were denied by a UK official.

Other reports spoke of two boats landing on a nearby beach and the soldiers using silenced weapons. Nato, the French military and the EU's anti-piracy force denied launching the raid. Somali officials, speaking anonymously, said that the target of the raid was a high-profile foreign leader in al-Shabaab, with one source identifying him as a Chechen.

Radio Shabelle in Mogadishu reported that one al-Shabaab fighter had been killed and others were injured. Somali security officials gave partly conflicting accounts.

"We understand that French troops injured Abu Diyad, also known as Abu Ciyad, an al-Shabaab leader from Chechnya. They killed his main guard, who was also a foreigner. The main target was the al-Shabaab leader from Chechnya," an intelligence officer based in Mogadishu, who gave his name as Mohamed, told Reuters.

Sheikh Abdiasis Abu Musab, a spokesman for al-Shabaab's military operations, told Reuters: "Westerners in boats attacked our base at Barawe beach and one was martyred from our side. No planes or helicopters took part in the fight. The attackers left weapons, medicine and stains of blood. We chased them."

There was immediate speculation that the target was the leader of al-Shabaab, Mukhtar Abu Zubeyr, also known as Ahmed Godane, who claimed responsibility for the four-day assault on the Westgate shopping mall. Godane said the Nairobi attack was in retaliation for Kenya's military deployment inside Somalia.

A CCTV image of one of the Westgate mall attackers. Photograph: AFP/Getty Images

Also on Saturday Kenya's military confirmed the names of four al-Shabaab fighters implicated in the Westgate mall attack. Major Emmanuel Chirchir said the men were Abu Baara al-Sudani, Omar Nabhan, Khattab al-Kene and Umayr – names that were first broadcast by a local Kenyan television station. "I confirm those are the names of the terrorists," he said in a tweet to Associated Press.

Publication of the identities supports CCTV footage from the Nairobi mall published by a private TV station that shows no more than four attackers, contradicting earlier government statements that 10-15 attackers were involved.

They are seen calmly walking through a storeroom inside the complex, holding machine guns. One of the men's legs appears to be stained with blood, although he is not limping, and it is unclear if the blood is his.