Balad Wayne, near the Ethiopian border, has changed hands several times in recent months.
It was a stronghold of al-Shabab fighters until last month when residents said Ethiopian forces in armoured vehicles moved in to chase out the fighters. Al-Shabab returned after the Ethiopians had pulled out.
Mohamud Agajog, a senior military official, confirmed to Reuters that the town was in government control again on Monday.
Meanwhile, there was also fighting in the capital, Mogadishu, where witnesses said a mortar shell fired by African Union (AU) troops killed seven people in the city's Bakara Market.
A spokesman for the AU peacekeeping force Amisom said they returned fire after a group of fighters attacked one of their bases. He said he was not aware of any casualties.
In the southern port city of Kismayo, hundreds of residents took to the streets to demonstrate against growing tensions between al-Shabab and another anti-government group, Hizbul Islam.
Hizbul Islam forces expelled al-Shabab leaders from Kismayo over the weekend, just days after al-Shabab unilaterally named its own local administration.
The port, which is a key source of income for the fighters through taxation, was closed because of the possibility of clashes, and residents said more fighters set up checkpoints to block roads.
Sheikh Hassan Yaqub, the al-Shabab spokesman in Kismayo, said the group would "take action" against its rivals soon.
Armed opposition movements control large parts of the country, with the influence of the government of Sharif Ahmed, the president, limited to only small areas in central Somalia and parts of Mogadishu.
Violence in Somalia has killed more than 18,000 civilians since the start of 2007 and driven 1.5 million people from their homes.