Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — The U.S. military plans to scale back its role in Somalia and curtail airstrikes against al-Shabab insurgents after having taken out many of the group's senior operatives, two senior U.S. officials told NBC News, the latest signal the Trump administration is looking to cut the number of troops deployed around the world.

The move reflects an assessment by the administration that while the Shabab insurgency remains a threat to the Somali government and neighboring countries, it does not pose a direct danger to the U.S., current and former officials said. And it follows President Donald Trump's abrupt announcement last month that he had ordered U.S. forces out of Syria and asked for plans to be drawn up for a possible drawdown in Afghanistan.

Former officials and counterterrorism experts say if the Trump administration presses ahead with its plans it could create a dangerous opening for al Qaeda, ISIS and other extremists to carve out sanctuaries and launch terrorist attacks on U.S. and Western targets.

In a statement, Defense Department spokesperson Navy Cmdr. Candice Tresch said, "There have been no recent policy changes regarding U.S. operations in Somalia. We continue to support the Federal Government of Somalia's efforts to degrade al Shabab."

The planned change also illustrates a broader strategic shift by the U.S. military to reduce forces devoted to counterterrorism operations in Africa and focus more on traditional adversaries such as Russia and China.

At the start of his term, Trump initially deployed additional troops to Somalia and gave commanders more latitude to call in air power, opening the way for an increase in bombing raids against Shabab militants waging war against the Somali government.

But under guidance issued by Defense Secretary James Mattis, who resigned last month, the military "is narrowing its mission a bit" in Somalia, one senior official, who spoke on condition of anonymity, told NBC News.

Somali soldiers patrol on the scene after a truck bomb exploded in Mogadishu on Oct.15, 2017. Mohamed Abdiwahab / AFP/Getty Images file

Part of the reason for the change was that U.S. military aircraft had already taken out many senior leaders in the Shabab insurgency.

"I would say we're running out of targets," the official said.

Under the plan, responsibility for bombing militants in Somalia would be shifted to the CIA, officials said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

That would likely mean pulling out some U.S. special operation forces that help pilots pinpoint targets, including for offensives carried out by African Union-led troops. The Pentagon has about 500 personnel in Somalia, including troops, civilians and contractors, according to U.S. Africa Command.

It remained unclear how many U.S. forces would remain on the ground under the planned shift.

The CIA, unlike the U.S. military, is not equipped to deploy hundreds of personnel on the ground to direct air strikes, and would almost certainly carry out fewer bombing raids. The agency could target gatherings of Shabab militants but would not be well-positioned to provide air power for a ground offensive by Somali government fighters or African Union troops, former officials said.

The U.S. has ramped up bombing raids on Shabab targets over the past year, carrying out 47 strikes in 2018, up from 35 in 2017, according to U.S. Africa Command.

The U.S. military said it conducted an airstrike Wednesday near Dheerow Sanle, killing an estimated 10 militants. And on Dec. 19, it bombed Shabab targets in two strikes, killing 11 militants.

U.S. officials suggested that while Shabab militants stage attacks in Somalia and against neighboring countries, they did not pose an imminent national security threat to the U.S.

"Not every nasty character out there is a threat to the U.S.," said the official, who added that it was time that Somalia's government takes the lead in the fight.

"Do we want to do the Somali government's job for it?"

The director of national intelligence, Dan Coats, has described Shabab as "the most potent terrorist threat to U.S. interests in East Africa."

U.S. Africa Command said the insurgency operates in southern and central Somalia "to plot and direct terror attacks, steal humanitarian aid, extort the local populace to fund its operations, and shelter radical terrorists."

Last month, the insurgents detonated a bomb at a military checkpoint near Somalia's presidential palace, killing at least 16 people and wounding more than 20 others.

The group has a long-running relationship with al Qaeda, and experts say the insurgency remains resilient and unwilling to lay down its arms or reconcile with the Somali government.

"The United States would be taking a gamble not entirely unreasonable — that this is a parochial issue and not a direct threat to the United States," said a former U.S. adviser on counterterrorism.

More than 10 years ago, Shabab controlled the capital, Mogadishu, and large swaths of territory before it was rolled back by African Union forces. But the Somalia government has struggled to extend its authority and to hold territory once the insurgents are cleared out of an area.

The revised U.S. role comes as the African Union force, or AMISOM, has started withdrawing its troops. The 20,000-strong AU mission plans to hand over security duties to the Somali army by 2020.

After a visit to Somalia earlier this year, the ranking Democrat on the Senate Armed Services Committee, Sen. Jack Reed of Rhode Island, expressed concern that Somalia was still "a long way off" from being a stable country with forces that could secure its territory.

"I think Somalia and West Africa are seen as more on the periphery of terrorism challenges by this (White House) leadership," said Joshua Geltzer, a former senior director for counterterrorism on the White House National Security Council and now a professor of law at Georgetown University.

But he said that there was a risk that the U.S. was cutting back resources and attention too soon, creating an opportunity for Shabab to rebuild a safe haven in Somalia.

"If you make the choice to take the foot off the gas prematurely, you may find you have a bigger investment later," Geltzer said.