Two car bombs exploded near the Sahafi Hotel and the Criminal Investigations Department (CID) on Friday afternoon, before a third bomb, placed in a three-wheeled “tuk-tuk”, exploded on a busy street near the hotel.
According to the police, a group of gunmen then tried to access the hotel but were killed by armed guards.
“We have confirmed 39 civilians died and 40 others were injured in yesterday’s blasts,” Mohamed Hussein, a police officer in the city told the Reuters news agency.
“The death toll may rise because some people are still missing.”
Some of the victims were burned beyond recognition when one of the car bombs exploded next to a minibus, police said.
“I’ve pulled many dead bodies from the cars,” said Mohamed Aden, a witness of the attack.
“The number of casualties is unknown as bodies are still being pulled from the burning cars,” he told Al Jazeera.
Hussein Nur, a shopkeeper who suffered light shrapnel injuries on his right hand, said: “The street was crowded with people and cars, bodies were everywhere.
“Gunfire killed several people, too.”
Al-Shabab, which is fighting to overthrow Somalia’s government, claimed responsibility for the attack.
The armed group was forced out of the capital and other major urban areas by Somali and African Union multinational forces in 2011, but continues to carry out deadly bombings and attacks in Mogadishu and elsewhere.
Targets have included hotels, military checkpoints and the presidential palace.
Last year, at least 358 people were killed in the deadliest attack in the country’s history, when a car bomb exploded at a busy road junction, flattening nearby homes and businesses.
Under US President Trump, air attacks in the Horn of Africa country have increased, with the Pentagon carrying out more than 25 raids, including drone attacks, since January.
Last month, the Pentagon said it killed more than 60 al-Shabab fighters in an air attack near the city of Harardhere.
There are currently around 500 US troops in the Horn of Africa country.