He provided no specifics but stressed that the US remained concerned about the threat posed by al-Shabab, which he called "an extension of al-Qaida," the extremist group that planned the September 11, 2001, attacks on the United States from Afghanistan.
"They do have some reach and they could if left unattended conduct operations against not only US interests in the region but also against the homeland," he said.
"So they require attention."
Noting that Somalia remains a dangerous place for Americans, he said that a CIA officer was killed there recently.
The acting secretary of defense, Christopher Miller, made a brief visit to Somalia last week and met with US troops.
Depending on what remains of the US presence in Somalia when he takes office January 20, President-elect Joe Biden could reverse Trump's drawdown or make other adjustments to reflect his counterterrorism priorities.
The US military also has a presence in neighbouring Djibouti on the Bab al-Mandab Strait.
Army General Stephen Townsend, head of US Africa Command, said in a written statement that the US contingent in Somalia will "decrease significantly," but he offered no specifics.
"US forces will remain in the region and our tasks and commitment to partners remain unchanged," he said.
"This action is not a withdrawal and an end to our efforts but a reposition to continue our efforts in East Africa," he added.
Rep. Jim Langevin, a Rhode Island Democrat, criticised the Trump pullback in Somalia as a "surrender to al-Qaida and a gift of China." Langevin is chairman of the House Armed Services Committee's Intelligence and Emerging Threats and Capabilities Subcommittee.
"When US forces leave Somalia in response to today's order, it becomes harder for diplomats and aid workers to help people resolve conflicts without violence and loss of life," Langevin said.
"With upcoming elections in Somalia and conflict raging in neighbouring Ethiopia, abandoning our partners could not come at a worse time."
Langevin said China will use the opportunity to build its influence in the Horn of Africa.
The Pentagon said the drawdown in Somalia does not mark the end of US counterterrorism efforts there.
"As a result of this decision, some forces may be reassigned outside of East Africa," it said.
"However, the remaining forces will be repositioned from Somalia into neighbouring countries in order to allow cross-border operations by both US and partner forces to maintain pressure against violent extremist organisations operating in Somalia."
It added: "The US will retain the capability to conduct targeted counterterrorism operations in Somalia, and collect early warnings and indicators regarding threats to the homeland."
The nature of the threat posed by al-Shabab and the appropriate US response has been a matter of increasing debate in the Pentagon, which has been looking for opportunities to shift its focus toward China as a greater long-term challenge.
A Defense Department watchdog report last week said US Africa Command has seen a "definitive shift" this year in al-Shabab's focus to attack US interests in the region.
Africa Command says al-Shabab is Africa's most "dangerous" and "imminent" threat.