At least 10 Somali soldiers were killed in the attack that began when militants detonated a large truck bomb. Al-Shabaab is an al-Qaida-linked militant group that seeks to impose Sharia law.
The militants drove a truck loaded with explosives to the main entrance of the base in Bala Gudud, about 40 miles (70 kilometers) from the port town of Kismayo and then stormed the base.
"There was an attack on the military base in Bala Gudud this morning... the initial information indicates that more than 10 soldiers were killed," Abdulahi Mohamed, a senior security official, said by phone.
"There was a car bomb blast and gunfire followed. The forces retreated from the base initially but they later regained control," he added.
Local villagers said the militants temporarily took control of the camp and the village.
"Some people in Bala Gudud told us the militants looted the camp ... they burned down everything and left," Ahmed Mohamud, a resident said.
Both al-Shabaab and the government claimed to have killed dozens of their opponent's fighters, respectively.
Abdiasis Abu Musab, al-Shabaab's military spokesman, said: "This morning, we stormed the Jubaland base near Bula Gudud. We killed 26 soldiers and burnt two cars."
The militants left the base after taking weapons, ammunition and several vehicles, he added.
Abdiasis Abu Musab, al Shabaab's military spokesman, said: "This morning, we stormed the Jubbaland base near Bala Gudud. We killed 26 soldiers and burnt two cars."
A short statement on a pro-Shabaab website, citing the group's Andalus radio, said: "The Mujahedeen fighters took control of Bala Gudud, there were many enemy deaths and three technical vehicles were looted."
The jihadists seek to impose Sharia law, and have vowed to overthrow Somalia's fragile government, which is kept in place with international support.
Shabaab militants were forced out of the capital, Mogadishu, in August 2011 and lost most of their other strongholds in Somalia.
But they still control large areas of countryside, from where they launch guerilla-style operations and suicide bomb attacks on the capital and the military bases belonging to the Somali government and international forces.
Regional Security Minister Abdirashid Janan said the heavily armed militants stormed the base. After an initial retreat, he said the soldiers fought back
"Our government soldiers resisted the attack," said Janan, "and the fight is now ongoing around the area."
bik/jm (AFP, Reuters, dpa)