Al-Shabab attackers set off two car bombs outside a police base in Somalia's capital before gunmen stormed inside, leaving at least 10 people dead, police said.
The armed group quickly claimed responsibility for the assault on the headquarters of Somalia's Criminal Investigation Department (CID) in Mogadishu on Sunday.
It was the second major operation in the city this week by the fighters, who have kept up their guerilla war on the Western-backed government in the face of US drone strikes and African peacekeeping forces.
Heavy gunfire rang out inside for about half an hour after the first blast, said witnesses.
The bodies of four civilians lay in the street near the compound which was partially destroyed. A kiosk near the wall caught fire.
"At least 10 people, including four militants, five civilians and a soldier, died in today's attack," Hussein Ali, a police officer, told Reuters.
At least 15 people were wounded, Ali added.
Al Shabab's military operations spokesman, Abdiasis Abu Musab, said one of its suicide bombers had started Sunday's attack by ramming a car bomb into the building's gate.
Witness Mohamed Abdi told the DPA news agency: "I saw a vehicle [driving] into the gates of the Criminal Investigation Department at a high speed and then a huge blast went off."
Somalia's Internal Security Minister, Abdirizak Mohamed, tweeted: "After 2 explosions 3 AS attackers who tried to enter the CID were killed, no casualties on our forces, will update you on civilian casualties".
In al Shabab's first attack this week, 13 people were killed when two car bombs went off at the gate of the African Union's main peacekeeper's base on Tuesday.
Security analysts had warned that the group could step up its attacks, taking advantage of the distraction caused by campaigning for a presidential election due in August.
Al-Shabab, seeking to impose power, has also launched attacks in Kenya and Uganda, which have contributed troops to the African Union peacekeeping force.
"Last week, al-Shabab used a former member of parliament as a suicide bomber," said Al Jazeera's Mohammed Adow. "Al-Shabab want to prove they are not just targeting and radicalising children, they are also targeting the so called cream of society."
He added: "People have lost hope in the current government [for a lack of security]."
Source: Al Jazeera and agencies