The U.S. military is sending dozens of regular troops to Somalia in the largest such deployment to the Horn of Africa country in roughly two decades.

The United States pulled out of Somalia after 1993, when two helicopters were shot down in the capital, Mogadishu, and bodies of Americans were dragged through the streets. Even now, Somalia's fragile central government is struggling to assert itself after the nationwide chaos that began with the fall of dictator Siad Barre in 1991.

The U.S. Africa Command on Friday said this deployment is for logistics training of Somalia's army, which is battling the extremist group al-Shabab that emerged from the country's years of warlord-led conflict. About 40 troops are taking part.

The U.S. in recent years has sent a small number of special operations forces and counter-terror advisers to Somalia, and President Donald Trump recently approved an expanded military role there. It includes carrying out more aggressive airstrikes against al-Shabab and considering parts of southern Somalia areas of active hostilities.

The country's new Somali-American president, Mohamed Abdullahi Mohamed, last week declared a new offensive against the extremist group, which is based in Somalia but has claimed responsibility for major attacks in East Africa, including the Garissa University attack in neighboring Kenya in April 2015 that killed 148 people.

Al-Shabab also caused alarm in February 2016 when it claimed responsibility for the bombing of an airliner that made an emergency landing with a gaping hole in the fuselage shortly after taking off from Mogadishu.

The extremist group this week announced that its recent escalation of deadly attacks in Mogadishu and elsewhere is in "doubled response" to Trump's approval of expanded U.S. military efforts. On Sunday, Somalia's new military chief survived a suicide car bomb attack following his swearing-in, while 13 people were killed. A day later, a suicide bombing at a military academy in Mogadishu killed at least five soldiers.

Al-Shabab was chased out of Mogadishu several years ago by national and African Union multinational forces but still controls some rural areas. Meanwhile, fighters pledging allegiance to the Islamic State group have emerged in the northern part of the country.

Pressure is growing on Somalia's army to assume full security for the country as the 22,000-strong African Union force plans to leave by the end of 2020. Last month, the head of the AU mission said Somalia's army has been unable to take charge as expected.

The AU force will begin withdrawing in 2018, "and if this departure begins prior to Somalia having capable security forces, large portions of Somalia are at risk of returning to al-Shabab control or potentially allowing ISIS to gain a stronger foothold in the country," the head of the U.S. Africa Command, Commander General Thomas Waldhauser, said last month.