(CNN)U.S. Special Operations forces came under fire from Al-Shabaab militants in Somalia Thursday when a mission to help Ugandan troops turned into unexpected combat for the Americans.

The incident occurred west of Mogadishu, according to a U.S. military official familiar with reports from the scene. No U.S. troops were wounded in what quickly turned into a firefight.
Ugandan troops, who are in the country as part of African forces backing the Somali government, had been called in to clear an illegal checkpoint being run by Al-Shabaab, the al Qaeda affiliate in Somalia. The Ugandans came under fire from an estimated 20 militants, the official said.
When the Ugandans were unable to completely suppress the Al-Shabaab fire, the U.S. "advise and assist" team, which was nearby, called in an airstrike on the checkpoint. The Americans had thought all the militants were either dead or had fled so they moved out from a rear position to where the Ugandans were. At that point, gunfire erupted again, the official said. The Special Operations forces quickly returned fire.
Five militants were killed in the operation, the official said.
The U.S. maintains a force of about 50 troops in Somalia to advise and assist both Somali and other African forces operating in Somalia. They are not expected to be in combat but are prepared if they come under fire, the official said. Helicopters, drones and manned aircraft are available for quick reaction airstrikes, the official noted.