MOGADISHU, Somalia — The struggling transitional government and its allies have undertaken a limited offensive against radical Islamist insurgents, attacking their positions in several places over the past few days, Somali officials and witnesses said on Monday.

The fighting started on Saturday near the Kenyan border, and by Sunday night at least one town, Belet Hawo, had switched hands, with government-allied militias pushing out the insurgents. The development appeared to be an unexpected setback for an insurgent movement that has been emboldened in recent months by the dysfunction of the government in this chronically unstable country.

Much of Somalia is ruled by the Shabab, a group of radical Islamist rebels who have sworn allegiance to Al Qaeda. Somalia's government barely controls just a few blocks of the capital.

But it seems that moderate Islamist militias loosely allied with the government and fiercely against the Shabab are playing a bigger role. The fighting near the Kenyan border was led by Col. Barre Hiiraale, a former Somali army commander and local warlord, who is also a member of parliament. Colonel Barre's troops had been trained in Ethiopia and are based just inside the Somali border.

Witnesses said that after Colonel Barre's forces took over Belet Hawo, residents took down the black Shabab flags that had been flying in the town and hoisted the blue and white national Somali flag.

"Today's victory is a gain for Somalis, the Somali flag and freedom," said Somalia's information minister, Abdirahman Omar Osman, in a statement. "Government forces will continue their struggle until they liberate the entire country from the brutal rule of al Shabab."

The fighting seemed to pick up on Monday, with forces from Ahlu Sunna Wal Jamaa, a large moderate Islamist militia, attacking Shabab positions outside Beletwein, a strategic town along the Ethiopian border. According to witnesses, at least 10 people were killed.

"We were really shocked by the weird sounds of the big guns this morning," said Osman Mose, a Beletwein resident. "We can't know what's next. Most of the residents are fleeing to the villages. But the Shabab are regrouping now inside the town."

Shabab officials said they had received "intelligence reports" indicating that Ahlu Sunna was planning more attacks in central Somalia.

"But we will confront them," said Sheik Yusuf Sheik Isse, a local Shabab chairman.

The Shabab have also vowed to crack down on a popular mobile money transfer service in Somalia, saying it was a threat to the Muslim-owned economy, even though the money transfer service, which many Somalis use to pay bills, is owned by Muslim Somalis.

The Somali government called the Shabab threat to the service a barometer of the group's ultimate aim.

"The extremists are against innovation, entrepreneurship and economic development of the country," said Somalia's treasury minister, Abdullahi Mohamed Ali, in a statement. "The business community should now see the importance of supporting the government in getting rid of these militias. A strong government would protect their businesses."