Al-Shabab fighters perform military exercises in Somalia’s Lafofe area south of Mogadishu in 2011. (Farah Abdi Warsameh/AP)

A member of U.S. Special Operations forces was killed in Somalia on Friday and four other U.S. service members were wounded, marking the first time an American has died in action in Africa since four U.S. soldiers were killed in an ambush in Niger late last year.

The Americans were conducting an operation against the al-Qaeda-linked extremist group al-Shabab alongside partner forces from Somalia and Kenya when they came under enemy mortar and small-arms fire, U.S. Africa Command said in a statement. The incident occurred Friday afternoon .

The Pentagon did not identify the U.S. commando who was killed, pending notification of next of kin.

The U.S. service members were assisting approximately 800 local troops as the group conducted a multiday operation to liberate villages from al-Shabab control in the Jubaland region and clear the extremists from contested areas, according to the U.S. military.

The forces were also setting up “a permanent combat outpost” to help expand the Somali government’s control over the region, where the Islamist militant insurgency for years has destabilized the East African nation, particularly in rural areas. 

U.S. forces were offering “advice, assistance and aerial surveillance during the mission,” U.S. Africa Command said, noting that the mission was designed to increase the Somali government’s ability to provide services to innocent civilians under al-Shabab rule.  

“The population in the region had historically supported the government, and the Somali forces had prepared for this mission by coordinating heavily with and securing the support of local authorities ahead of time,” U.S. Africa Command said. “The overarching goal in Somalia for the Department of Defense is to help the [government] provide a safe and secure environment for the Somali population.” 

Three of the four wounded U.S. service members were evacuated to receive additional medical treatment, the military said. The fourth received sufficient medical care on the scene.

President Trump wrote a message on Twitter Friday night, saying, “My thoughts and prayers are with the families of our serviceman who was killed and his fellow servicemen who were wounded” in Somalia. “They are truly all HEROES.”

Though U.S.-backed operations and airstrikes have dented al-Shabab, the militants have continued to carry out deadly attacks in Somalia, including a bombing in October that left some 300 people dead in the capital of Mogadishu.

The United States has about 500 troops in the country, according to U.S. officials, many of them Special Operations troops such as Navy SEALs and Army Green Berets. The Americans train and support Somali troops and give them intelligence information to help in their campaign against al-Shabab, in addition to helping with surveillance and airstrikes. 

The extent to which U.S. troops are assisting behind the scenes or fighting shoulder to shoulder with local troops has become a point of contention, not only in Somalia but also in other parts of the world where U.S. service members are helping fight extremist groups by backing proxy forces.

Friday’s incident marked the first time a U.S. service member has died in action in Somalia since Navy SEAL Kyle Milliken, a senior chief petty officer, was killed in May of last year in a firefight with al-Shabab militants.

Milliken’s was the first U.S. combat death in Somalia since 1993, when 18 U.S. service members died battling Somali militiamen in an episode chronicled in the book and film “Black Hawk Down.” Though the Pentagon initially described Milliken as operating behind Somali troops, U.S. officials later acknowledged that U.S. Special Operations troops had been fighting together with the Somali forces.  

 U.S. military operations in Africa have come under greater scrutiny since an Oct. 4 ambush by Islamic State militants in the West African country of Niger left four U.S. soldiers dead. 

A U.S. military report on that incident publicized by the Pentagon last month without being fully released found that multiple individual and institutional failures left the U.S. troops vulnerable to the ambush.

Marine Gen. Thomas D. Waldhauser, who heads U.S. Africa Command, said at a Pentagon news conference that he had taken steps to better ensure the safety of U.S. service members in future operations. 

“We are now far more prudent,” Waldhauser said. “The missions we actually accompany on have to have some type of strategic value in terms of the enemy we’re going against. Do they have a strategic threat to the United States?”

Militants affiliated with al-Shabab have threatened to conduct attacks against the United States, and the U.S. military has said the group poses a direct threat to U.S. interests and allies in the region. Though the group remains primarily a regional threat, the U.S. military has deployed to Somalia to prevent the extremists from operating freely in a safe haven.