Mohamud Haji Ali was shot by a group of gunmen in the Shibis district of Mogadishu and the Islamist rebel group later claimed responsibility.
“Police and security forces reached the scene later to investigate and pursue the militants,” police officer Ibrahim Nur told Reuters.
“The officer [Haji Ali] had no guards with him when he was killed.”
The gunmen then managed to escape the scene.
“We are behind the killing of the national security general called Mohamud Haji Ali,” said Abdiasis Abu Musab, a spokesperson for al-Shabaab.
Somalia recently upped its battle against al-Shabaab with more military operations and a new soft power programme to deter young people from recruiting with the Islamist group.