The early morning attack in the village of Qayib, which included suicide car bombs, comes as government forces have made a number of battlefield gains against al Shabab in the last three months, regaining territory with the help of clan militias.
"We had information that al Shabaab was attacking us, so last night we were all vigilant waiting for them. We hit their cars that had been loaded with bombs with rocket propelled grenades, foiling them before they entered the base," Ismail Abdulle, one of the clan fighters told Reuters from Qayib.
The information minister in Galgaduud, Ahmed Shire Falagle, said government forces had foiled the attack and was in control of Qayib.
However, Al Shabaab's military operations spokesman, Abdiasis Abu Musab, disputed that account. He said the fighters had taken Qayib, killed soldiers and stolen military vehicles. He also acknowledged al Shabaab's own forces had suffered casualties in the attack.
Both sides often give conflicting accounts of battles. Somalia's local information minister said he would provide an update on casualties later.
Somali state television, citing a ministry of information statement, also reported on Friday that 15 al Shabaab fighters had been killed in an air raid at Bulo Madino in the Lower Shabelle region.
The group has killed tens of thousands since 2006 in its fight to overthrow Somalia's Western-backed central government and implement its strict interpretation of Islamic law.
At least 120 people died in twin car bombs bombs at the education ministry in the capital Mogadishu on Oct. 29, the deadliest blasts in five years.