A U.S. military airstrike has killed 18 al-Shabaab extremists after U.S. and local forces came under attack in southern Somalia, the U.S. Africa Command said Saturday.

The airstrike was carried out in self-defence on Friday about 50 kilometres northwest of the port city of Kismayo, the U.S. statement said.

Two other al-Shabaab extremists were killed by Somali forces "with small arms fire during the engagement," it said.

No U.S. or partner forces were killed or injured, an AFRICOM spokesman, Nate Herring, told The Associated Press. The airstrike was carried out after extremists were "observed manoeuvring on a combined patrol" of U.S. and Somali forces, while the U.S. also responded with "indirect fire," Herring said.

20 airstrikes this year

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

U.S. military involvement in Somalia has grown since U.S. President Donald Trump early in his term approved expanded operations against al-Shabaab. Dozens of drone strikes followed. Late last year the military also carried out its first airstrike against a small presence of fighters linked to the group Islamic State in Iraq and Syria (ISIS) in northern Somalia.

Since the expanded operations, two U.S. military personnel have been killed in Somalia.

A service member was killed in May 2017 during an operation about 60 kilometres west of Mogadishu. And in June, one U.S. special operations soldier was killed and four U.S. service members wounded in an "enemy attack" as troops with Somali and Kenyan forces came under mortar and small-arms fire in Jubaland.

The U.S. currently has about 500 military personnel in the Horn of Africa nation.

Al-Shabaab, which seeks to establish an Islamic state in Somalia, was pushed out of Mogadishu in recent years but continues to control rural areas in the south and central regions. Its fighters continue to attack the bases of a multinational African Union force that remains largely responsible for security as Somalia's fragile central government tries to recover from decades of chaos.

In the next few years Somali forces are expected to take over responsibility for the country's security as the AU force withdraws. Concerns about their readiness remain high, and the UN Security Council recently voted to delay the handover's target date to December 2021.