Zakia Hussein Ahmed, deputy police commander, said the arrests were made in an offensive conducted in two different districts in the capital.
"Our forces detained on May 1 two militants who killed Abdullahi Ali Ma'ow, a government soldier, in Waberi District," Zakia told journalists in Mogadishu on Sunday evening. "They also apprehended two other militants in Mogadishu's Heliwa District."
She said that Somali forces also seized weapons like anti-tank mines and bombs that the militants intended to carry out attacks during Ramadan.
Mogadishu is on high alert as police forces blocked the main roads of the capital to prevent possible militant attacks.
Somali security forces, backed by African Union Mission in Somalia, chased al-Shabab militants from the capital in August 2011, but the militants are still able to conduct attacks targeting government installations, hotels, restaurants and public places.