The ministry described it as a planned operation in a forest near the village of Ali Foldhere in Middle Shabelle on Wednesday night, but al Shabab and one clan fighter said the fighting arose from an attack by the militants.
The government, supported by clan militias and African Union troops, says it has killed more than 600 members of al Shabab and recaptured 68 settlements over the last three months, as part of concerted efforts to end the militants' control over large portions of the Horn of Africa country.
On Sunday al Shabab stormed a heavily guarded hotel near the president's residence in Mogadishu, killing nine people.
Al Shabab, an al Qaeda franchise that is seeking impose its interpretation of Islamic law across the country, frequently stages deadly attacks in the capital Mogadishu and elsewhere.
Al Shabaab's restrictions on deliveries of international aid have compounded the impact of the worst drought in four decades, officials say, leaving Somalia on the brink of famine.