Updated

A U.S. special operations soldier was killed and four U.S. service members were wounded Friday in an "enemy attack" in Somalia, the U.S. military said.

It was the first public announcement of a U.S. military combat death on the African continent since four U.S. service members were killed in a militant ambush in Niger in October.

President Donald Trump shared his condolences in a Twitter message Friday evening.

“My thoughts and prayers are with the families of our serviceman who was killed and his fellow servicemen who were wounded in Somalia,” Trump tweeted. “They are truly all HEROES.”

U.S. troops with Somali and Kenyan forces came under mortar and small-arms fire in Jubaland, Somalia around 2:45 p.m. local time, U.S. Africa Command said in a statement.

The joint-coalition forces had been conducting an operation against al-Shabab militants about 217 miles southwest of the capital, Mogadishu, when the attack occurred, the statement said. The operation aimed to drive out the Somalia-based extremist group al-Shabab from contested areas.

Three of the four U.S. service members were transferred for medical treatment while the fourth received medical care on the spot, the Washington Post reported.

Al-Shabab claimed credit for the attack, the SITE Intelligence Group said in a statement Friday.

The U.S. has about 1,000 special operations personnel in Africa. The last killing of a U.S. service member in Somalia was in May 2017 during an operation about 40 miles west of Mogadishu, Stars and Stripes reported.

Trump approved expanded military operations against al-Shabab in early 2017, leading to an increase in U.S. military personnel to more than 500 and the launch of dozens of drone strikes.

Al-Shabab, linked to al Qaeda, seeks to establish an Islamic state in Somalia. It was pushed out of Mogadishu in recent years but continues to control rural areas in the south and central regions.

Late last year U.S. drone strikes also began targeting a small presence of fighters linked to the Islamic State group in Somalia's north.

Somali officials have said civilians have been killed in more than one joint U.S. military operation with Somali forces. Earlier Friday, the U.S. Africa Command issued a statement in response to allegations that civilians had been killed in a May 9 operation, saying a "thorough review" found the allegations to be "not credible."

The October attack in Niger raised questions in Washington about the U.S. military presence across Africa as the Trump administration focuses counterterror efforts on a range of groups linked to Al Qaeda and the Islamic State group.

A Pentagon investigation into the Niger attack, parts of which were made public last month, found multiple failures but none that directly caused the ambush by Islamic State group-linked fighters.

The investigation has already triggered changes in the way military activities are carried out in Niger and elsewhere in Africa, including giving teams the option to use heavily armored vehicles and beefed-up firepower.

The Associated Press contributed to this report.