The claim by the Al-Qaeda linked insurgents, made by the group’s spokesman on an affiliated radio station, could not be immediately verified.
Local residents did confirm to AFP that fighting had taken place Sunday in the Lower Shebelle region, a hotly contested area where Shabaab’s spokesman said they had staged their ambush.
“The mujahedeen fighters stood over the dead bodies of 39 soldiers, among them senior commanders”, Abdiaziz Abu Muzab told Andalus radio.
The African Union has a 22,000 strong force in the country dedicated to fighting Shabaab and backing up the internationally backed government in the capital Mogadishu.
Residents said the AU troops were ambushed in the village of Golweyn some 120 kilometres (74 miles) as they escorted supplies along the road that connects Mogadishu to Lower Shebelle.
“Fighting broke out and continued for more than one hour”, said Ali Osman, a witness to the battle.
In April, a minibus travelling through Golweyn hit a landmine, killing at least 14 people.
That attack was also blamed on Shabaab, which has fought successive governments in Mogadishu and also carried out attacks in Kenya and Uganda.
Download our app and read this and other great stories on the move. Available for Android and iOS.