Eye-witnesses said the Shebab had taken over the camp and were looting the weapons stores, but the AU force in Somalia (AMISOM) insisted it was in control of the base.
Witnesses spoke of more than 20 bodies at the site, while the Shebab claimed to have killed 50. AMISOM was unable to confirm any casualty figures.
"The base is still under AMISOM control, reports that the base has been taken over and our weapons captured are false," an AMISOM statement said without giving further details.
"The attack started with a suicide bomb explosion and the fighters stormed the base, engaging in fighting that continued inside the military camp for about 40 minutes," said Shebab spokesman Abdulaziz Abu Musab.
More From This Section
He claimed that "about 50 soldiers" were killed in the attack and that others drowned in a nearby river while fleeing.
"The mujahedeen fighters have taken complete control of the town and the military camp as well and looted all the heavy weaponry," Abu Musab said. "This attack was aimed to retaliate against the killing of innocent civilians in Merka by the Ugandan troops."
Mohamed Shire, a Somali military commander in the area, said there had been "a heavy explosion and fighting."
Witnesses said Shebab fighters had breached the barricades around the camp.
"Many people stormed the camp after AU soldiers fled, and they started looting together with Al-Shebab," said local resident Hussein Idris, who said gunmen loaded corpses of AU troops onto trucks.
The Shebab has previously gathered the bodies of dead soldiers for use in propaganda videos of its attacks.
Another eyewitness, Ahmed Ali, said he had seen AMISOM troops fleeing the base, and had counted as many as 20 bodies.
"The fighters also looted weapons and ammunition," Ali said.
Another local eyewitness described how a Shebab suicide bomber first attacked the camp gates.