WASHINGTON — The U.S. military secretly sent a small team of advisors to Somalia last month to assist with operations against militants, the first time U.S. troops have been stationed there since two helicopters were shot down and 18 American soldiers were killed in 1993.

The three-man advisor detachment is based at the airport in Mogadishu, the Somali capital, where a force from multiple African nations attempting to stabilize the war-ravaged Horn of Africa country has its headquarters, U.S. officials said.

The U.S. soldiers assist a force of more than 18,000 under the auspices of the African Union, which has been heavily backed by the United States and other Western countries since deploying to Somalia in 2007 with logistics help, intelligence and planning, the officials said.

The Americans also are helping Somalia’s fledgling security forces, which have struggled to assert control beyond Mogadishu and have often been the target of fierce attacks from the Shabab, an Islamic militant group with ties to Al Qaeda that ruled large parts of southern Somalia before being driven from power by the African force.

Though the initial advisor presence is small, a senior Defense Department official said the U.S. was hoping to expand it in the coming year, signaling the possible return of a permanent U.S. presence in Somalia two decades after the battle recounted in the movie “Black Hawk Down” drove the U.S. military out.

“This is something that’s been in the works for a while,” said the U.S. official, who was speaking anonymously because he was not authorized to discuss details of the U.S. effort.

Eventually, troops will be on six-month rotations, deploying from a U.S. base in nearby Djibouti, he said.

The advisors “liaise with Somali security forces and provide planning and advisory support to” the African Union troops, according to a statement issued by the Pentagon.

The African forces have seen their efforts to defeat the Shabab hampered by shortages of attack helicopters, armored vehicles and timely intelligence, officials familiar with the operations have said.

It was unclear whether U.S. Africa Command, which oversees U.S. military operations in Somalia, was planning to increase the equipment provided to the African troops and whether the U.S. would eventually take on a direct role in the stabilization effort.

Concern about the Shabab has led the U.S. to pay close attention to Somalia, with drone flights from the base in Djibouti and periodic raids by special operations troops.

In October, U.S. Navy SEALs stormed a coastal compound in southern Somalia hoping to capture a Shabab operative believed to have played a role in the group’s deadly attack the previous month on a shopping mall in Kenya, but the commandos were driven off in a firefight without capturing him.

Though forced out of Mogadishu in 2011, the Shabab has remained a potent threat in rural areas, where it seeks to impose strict Islamic law. Its leaders announced that the group was joining forces with Al Qaeda two years ago, and U.S. intelligence analysts say some members have shown signs of wanting to mount attacks outside Somalia, including on U.S. targets.