Somali government forces and allied militias have recaptured a strategic town held by Al-Shabaab jihadists since 2016, President Hassan Sheikh Mohamud said on Tuesday.

The army and local clan militias known as "Macawisley" have retaken swathes of territory in the central states of Galmudug and Hirshabelle in recent months in an operation backed by US air strikes and an African Union (AU) force, ATMIS.

Pro-government forces entered the town of Adan Yabal in Hirshabelle, around 220 kilometres (140 miles) northeast of the capital Mogadishu, after the Al-Qaeda-affiliated rebels withdrew, the president said.

"Somali government forces are in Adan Yabal this morning... They (Al-Shabaab) did not even fight and vacated instead," Mohamud said in a televised address.

Colonel Mohamed Ali, one of the operation's commanders, told AFP the rebels fled when they learned the army was approaching.

"We have taken the town without any resistance and the army is in full control," he added.

Military sources said the jihadists pulled out on Monday evening.

ATMIS, which supported the operation with helicopters, said Al-Shabaab had used Adan Yabal as a training base.

The force welcomed its return to Somali government control.

The rebels, who have been waging a bloody insurgency against Somalia's internationally backed federal government for 15 years, also used the town as a logistics hub.

Mohamud accused Al-Shabaab of making off with electric pumps from the town's wells and forcing people to "flee with them, to be human shields."

The president, who declared an "all-out war" against Al-Shabaab after his election in May, said the effort to rid Hirshabelle and Galmudug of the group was in its "final stages" with only "pockets" of resistance remaining.

Forced out of the country's main urban centres around 10 years ago, Al-Shabaab remains entrenched in vast swathes of rural central and southern Somalia and continues to carry out deadly attacks in Mogadishu.

On October 29, 116 people in the capital were killed in two car bomb explosions at the education ministry, and eight civilians died in a 21-hour hotel siege on November 27.

AMISOM, a previous incarnation of the AU force in Somalia, seized Adan Yabal from the rebels in 2016 before ceding control a few months later after Ethiopian troops withdrew.