The ministers of defence, interior and justice were unharmed after a landmine exploded under a vehicle near the port of Merca, they say.
A governor told the BBC there had been a two-hour gunbattle near Jowhar.
This is the biggest town under the control of al-Shabab Islamists.
The al-Qaeda linked group has been driven out of most urban areas over the past two years still controls many rural areas of the country.
Middle Shabelle governor Abdi Jiinow told the BBC Somali service that al-Shabab had now gathered its forces around Jowhar, 90km (55 miles) north of the capital, Mogadishu, in order to defend the town.
He said three soldiers and 15 al-Shabab fighters had been killed in the fighting, which he said was the fiercest in the area for several months since pro-government advanced on the town.
The militant group has not yet commented on the fighting there.
But its Twitter feed said it had carried out the ambush on the ministerial convoy near Merca, south of Mogadishu.
It said several people had been killed – a claim backed by some independent sources in the area.
The area’s deputy governor told the BBC that four police officers escorting the ministers had been badly wounded.
Alongside the recent military gains, a new president took office in September, raising some hopes of a return to law and order after two decades of anarchy.