JOHANNESBURG -- The U.S. military says it has carried an airstrike that killed 18 al-Shabab extremists after U.S. and local forces came under attack in southern Somalia.

The U.S. Africa Command says in a statement the airstrike was carried out in self-defence on Friday about 50 kilometres (31 miles) northwest of the port city of Kismayo.

The statement says two other al-Shabab extremists were killed by Somali forces "with small arms fire during the engagement."

An AFRICOM spokesman says no U.S. or partner forces were injured. The spokesman says the airstrike was carried out after extremists were "observed manoeuvring on a combined patrol" of U.S. and Somali forces.

The U.S. has carried out more than 20 such airstrikes this year against the al-Qaida-linked al-Shabab, the deadliest Islamic extremist group in sub-Saharan Africa.