US President Donald Trump has ordered the withdrawal of nearly all US troops from Somalia by 15 January, the Pentagon has said.

The US has about 700 troops in the country helping local forces battle al-Shabab and Islamic State militants.

US officials said some of the troops would move to neighbouring countries, allowing for cross-border operations.

In recent months President Trump has issued similar orders to reduce US forces in Iraq and Afghanistan.

He has long called for US troops to come home and has criticised US military interventions for being costly and ineffective.

The withdrawal order – which would see troops redeployed just days before Trump leaves office – reverses the policy of former US defence secretary Mark Esper, who was sacked last month and favoured maintaining the US presence in Somalia.

US Defence Secretary Mark Esper, with US President Donald Trump,on May 15, 2020.

Donald Trump has reversed the policy of former US defence secretary Mark Esper, on the right. Photo: AFP

A Pentagon statement said that the order to “reposition the majority of personnel and assets out of Somalia by early 2021” did not signify a change in US policy.

“We will continue to degrade violent extremist organisations that could threaten our homeland while ensuring we maintain our strategic advantage in great power competition,” it said.

However, some experts have warned that a US withdrawal could embolden militants in the Horn of Africa region.

Last month, US government inspectors advised against a withdrawal from Somalia, saying local forces would not be able to resist threats from militants without US support.

Somali lawmakers and officials have also said any US drawdown would be disastrous and a boost for terrorists.

Those US forces left in Somalia will be based in the capital Mogadishu, the Pentagon said.

The mission has received little attention in the United States, but has been considered a cornerstone of the Pentagon’s global efforts to combat al Qaeda.

The United States already pulled out of Somalia’s cities of Bossaso and Galkayo earlier this year. As of last month, US troops were still in the southern port city of Kismayo, Baledogle airbase in the Lower Shabelle region, and in the capital, Mogadishu.

Somalia has suffered decades of political instability but in recent years a peacekeeping force from the African Union along with US troops have reclaimed control of Mogadishu and other areas from al-Shabab – an al-Qaeda affiliate.

US presidents have been wary of intervention in Somalia since 18 special forces soldiers died fighting militias in Mogadishu in 1993, a battle dramatised in the film Black Hawk Down.

– BBC / Reuters