"The information we are getting indicates at least four people died and 12 others were wounded but we still don't have more details," security official Ibrahim Mohamed told AFP on Sunday.
He said "terrorist elements" had rammed two cars packed full of explosives into the headquarters of the police's criminal investigations department in the city centre.
At least two attackers were also killed, according to Ali Mohamed, a police officer.
Al-Shabaab Islamist militants say they struck Somalia's Criminal Investigations Department (CID) with a car bomb, Reuters news agency reports.
"A fighter rammed a suicide car bomb into CID then other armed fighters stormed inside. We are now fighting inside the CID building," Abdiasis Abu Musab, al Shabab's military operations spokesman said as quoted by Reuters.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
The news agency cites police as reporting seven people, including two attackers, were killed.
Twitter users have been posting pictures of smoke billowing into the sky, after they said they heard two loud explosions and gunfire in Mogadishu, the capital of Somalia, on Sunday morning.
The reports come after suicide bombers killed 13 people near the Aden Adde International Airport in Mogadishu on July 26. Al-Shabaab spokesman Abdulaziz Abu Musab claimed responsibility for the attack.
The al-Shabaab were forced out of the capital five years ago but continue to carry out regular attacks on military, government and civilian targets.
In recent months they have claimed attacks on military bases as well as civilian targets including hotels.
This year is considered critical for the group, which is eager to disrupt an expected change of government due in the coming months.
The news comes after suicide bombers killed 13 people near the Aden Adde International Airport in Mogadishu on July 26.
Al-Shabaab claimed responsibility for that attack.

