NAIROBI — The Somali militant Islamist group al-Shabab claimed a double bombing and siege of a hotel in downtown Mogadishu that began late Thursday and continued for 20 hours until Somali special forces cleared the area of attackers.

Police officials offered conflicting death tolls, but it appeared that at least 25 people were killed and at least 60 wounded.

The attack took place on a street lined with restaurants and shops in the heart of Somalia’s capital. Al-Shabab attacks Mogadishu frequently, and its deadliest operation — a truck bombing that killed more than 500 in 2017 — took place just a mile away on the same road.

Photos and videos of Thursday night’s attack posted to social media showed the hotel in flames and ambulances rushing to the scene. 

Ahmed Dahir, a waiter at Maka al-Mukarama Hotel, spent 15 hours under siege there. 

“I saw many bodies lying on the floor of the hotel. I have lost two of my friends, too. All I can say now is that I’m safe, with God’s grace,” he said in a telephone interview.

It was the third and most serious attack on the hotel, which is frequented by politicians and members of the Somali community abroad who are on trips home. It was not immediately clear whether the attackers had a specific target in the hotel or nearby.

In January, al-Shabab staged a similar siege at a hotel in Kenya’s capital, Nairobi, which also lasted almost 20 hours and resulted in 21 deaths. Kenya is one of the largest sources of foreign troops participating in an international effort against al-Shabab in Somalia.

Despite years of large-scale military assistance from neighboring African countries and the United States, Somalia’s army has struggled to prevent al-Shabab’s attacks in Mogadishu and across the country. A U.S.-trained contingent of the Somali National Army, called “Danab,” meaning lightning, ultimately ended the latest siege.

Al-Shabab aims to overthrow Somalia’s government, and before a large-scale offensive against the militant group in 2011, it controlled most of the country. The group now is limited to rural areas, but its ability to mount attacks has stunted Somalia’s economic growth and deepened a humanitarian crisis by preventing aid from reaching populations in areas the militants control. 

Under the Trump administration, U.S. airstrikes against al-Shabab have become far more frequent. More than 200 fighters have been killed in 23 strikes this year, according to the U.S. Africa Command.

Shortly after the siege was declared over on Friday, the U.S. Africa Command announced an airstrike that it said had killed 26 al-Shabab fighters. It did not disclose where in Somalia the strike took place. 

The Pentagon estimates that 3,000 to 7,000 al-Shabab fighters were in Somalia as of August 2018. The U.S. military has about 500 troops in Somalia, primarily in advisory roles.

Abdullahi Mire in Nairobi contributed to this report.