Sheik Abdiasis abu Musab, al-Shabab’s spokesman for military affairs, said they carried out the attack in the southern Mogadishu district of Afarta Jardiin.
“We have shot dead nine government soldiers in Mogadishu since Ramadan started. We shall continue and intensify the operation,” abu Musab said.
The group had previously said its gunmen shot dead three people on Sunday and killed another three government employees on Monday in two separate bomb blasts.
The government and African Union peacekeepers have stepped up security to try to stop the Ramadan attacks by al-Shabab, which has waged a seven-year campaign to impose its strict interpretation of Islamic law in the mainly Christian country.
The militants view people who work for the government, such as the security forces, as collaborators with non-Muslims due to the involvement in Somalia of African Union soldiers, the United Nations and Western powers trying to contain the group.
Police officer Nur Jamac said al-Shabab shot the three soldiers in the head on Tuesday as they talked in the street.
In the past year or so, al-Shabab has killed dozens of people in guerrilla-style assaults in Mogadishu, on U.N. offices, the presidential compound, parliament and the courts.
In a separate attack, police in Afgoye, a district 30 km southwest of Mogadishu, said two clan elders were assassinated by pistol-wielding assailants on Monday.
It was not immediately clear who was behind that attack, a senior police officer in Afgoye told Reuters.