Updated

U.S. airstrikes in Somalia killed four al-Shabab fighters in "self-defense," military officials confirmed to Fox News on Wednesday.

The extremists launched attacks on Somali troops and their U.S. advisers on Monday in a village near the port city of Kismayo, Cpt. Jennifer Dyrcz with U.S. Africa Command said.

Somali forces returned fire, killing several extremists, but the attack continued, according to military officials. The U.S. then conducted its strike, killing four fighters.

"Based on the threatening maneuver by Al-Shabaab fighters and their previous hostile engagement with the Somali forces, the U.S. conducted a self-defense strike to neutralize the threat," Dyrcz explained.

U.S. forces have carried out several airstrikes in Somalia in recent years, killing many al-Shabab leaders.

The extremist group is now mostly active in rural regions but continues to launch lethal attacks in many parts of this Horn of Africa nation, including the capital city of Mogadishu.

Kismayo is approximately 300 miles southwest of Mogadishu.

Fox News' Lucas Tomlinson and The Associated Press contributed to this report.