The U.S. military maintains a "small number" of troops in Somalia to support the fight against al-Shabab. U.S. officials have not disclosed how many American troops are deployed to Somalia.
The second attack on U.S. forces came Wednesday in central Somalia near the town of Galkayo, Davis said.
A Somali army unit conducting counterterrorism operations was near, but not in the immediate vicinity of, a small team of U.S. forces when the Somali soldiers came under fire from al-Shabab militants.
The Somali soldiers returned fire, then broke contact and rejoined with their nearby American advisers.
Soon afterward, the al-Shabab fighters "began to maneuver in an offensive manner against the consolidated Somali-and-U.S. force," Davis said.
"Based on their threatening maneuvers and the previous hostile engagement with Somali forces, the U.S. conducted a self-defense strike to neutralize the threat," Davis said.
That strike killed four al-Shabab militants, Davis said.
Al-Shabab is a locally run Somali extremist group that has pledged allegiance to al-Qaida. It is fighting an insurgency against the American-backed Somali government based in Mogadishu.
Andrew Tilghman is the executive editor for Military Times. He is a former Military Times Pentagon reporter and served as a Middle East correspondent for the Stars and Stripes. Before covering the military, he worked as a reporter for the Houston Chronicle in Texas, the Albany Times Union in New York and The Associated Press in Milwaukee.