The car bomb went off near the residence of appeals court chief Judge Abshir Omar, and security forces stationed outside the judge's house fought off gunmen who tried to force their way inside, police officer Mohamed Hussein said.
More than 35 were wounded in the attack, said Hussein, who raised the death toll to 11. Shortly after the detonation, at least four gunmen running on foot opened fire at nearby buildings and business, sparking clashes with security forces stationed nearby and hotel guards, he said.
Two witnesses said the blast ripped off part of the roof of Omar's house. The witnesses, shopkeeper Ahmed Mohamed and area resident Fatima Nur, reported hearing gunfire after the explosion and said smoke billowed from the site of the attack.
Al-Shabab, which is considered the deadliest Islamic extremist group in Africa, claimed responsibility for the attack. The al-Qaida-linked group said the Maka Almukarramah hotel, not the judge's house nearby, was the intended target.
Another witness, Sabir Abdi, said the hotel suffered significant damage and several people inside were injured. Dozens of cars were on fire along Maka Almukarramah Road, which is in a busy part of Mogadishu where restaurants and hotels are located.
Al-Shabab has targeted the Maka Almukarramah hotel multiple times in the past, including a March 2015 attack in which at least 18 people died. The hotel is frequently patronized by government officials.
Many of victims of Thursday's attack suffered horrific injuries and local hospitals were said to be struggling to cope with causalities. Some of the wounded lost limbs, said Sadiya Yusuf, a nurse at Daru Shifa, one of the hospitals treating victims.
The militant group, which opposes Somalia's federal government and wants to impose sharia law, has carried out many deadly attacks inside Somalia and elsewhere in the region, including in neighboring Kenya.
It was behind the deadliest attack in Somalia's history, a massive truck bombing that killed well over 500 people in Mogadishu in October 2017. Al-Shabab also said it was responsible for a January attack on a hotel and shopping complex in neighboring Kenya's capital of Nairobi that killed 21 people.
The U.S. has dramatically increased airstrikes against the extremist group since President Donald Trump took office. The U.S. military command for the African continent reported carrying out 50 strikes in Somalia in 2018.
This year, U.S. strikes targeting al-Shabab fighters have come at an even faster pace. The military command in Africa reported 23 as of Tuesday, including one in central Somalia that killed 20 militants and another the day before that killed 35.
Rodney Muhumuza contributed from Kampala, Uganda.