The death of Navy SEAL Kyle Milliken and the wounding of two more U.S. troops in Somalia this month marked the first deadly engagement for American forces in the country since the Battle of Mogadishu of October 1993. The two events differ in notable respects, not least in their magnitude—the battle of October 3-4, 1993, resulted in 18 Americans killed and 79 wounded. But both operations reflect the adverse conditions that U.S. special-operations forces, and the United States more broadly, face in the world’s most dysfunctional states.

Back in the summer of 1993, warlord Mohamed Farrah Aidid bedeviled an international coalition that was trying to restore order and build democracy in the midst of a vicious civil war in Somalia. A ruthless clan leader known for firing artillery into civilian neighborhoods and starving opposing clans into submission, Aidid had made himself the chief obstacle to the nation-building project. The Clinton administration had removed a large U.S. Marine force months earlier and transferred authority over the remaining international troops to the United Nations. Madeleine Albright, Clinton’s UN ambassador, declared at the time, “[W]e will embark on an unprecedented enterprise aimed at nothing less than the restoration of an entire country as a proud, functioning and viable member of the community of nations.”

When the marines had occupied Mogadishu, their relentless patrolling of city streets had kept Aidid and other warlords in check. Once they left, the Asian, European, and African peacekeepers under UN command did not maintain such a visible presence. Sensing weakness, the clan militias began resisting foreign efforts to monitor their weapons caches and limit their activities.

In August 1993, the killing of four U.S. soldiers by a bomb traced to Aidid convinced Clinton that the status quo had become untenable. Clinton was unwilling to send additional conventional forces to Somalia, owing to reservations among congressmen in his own party, some of whom were already calling for the removal of all U.S. forces from a situation they were certain would devolve into another Vietnam. But Clinton was open to sending special-operations forces, since their units were smaller and designed to maintain a low profile. Some in the special-operations community argued that their units could oust Aidid, demonstrating their ability to achieve strategic results without the participation of conventional forces. Clinton decided to send the Army’s most elite unit, Delta Force, to Somalia, along with a Ranger company and a detachment from the 160th Special Operations Aviation Regiment.

The operation of October 3, 1993, began auspiciously enough. Storming a three-story house in Mogadishu, the Delta operators rounded up several high-value targets without firing a shot. But then a rocket-propelled grenade felled one of the American Black Hawk helicopters flying nearby, forcing some of the U.S. ground troops to move toward its crash site. Caught in the middle of the city with no Somali security forces to assist, the Delta operators and Rangers came under attack on all sides from Aidid’s militiamen. By intermingling with women and children, the militiamen reduced their vulnerability to American fire, wary as the latter were of harming civilians. Most of the American units were able to hold out until the arrival of reinforcements early the next day, but only at heavy loss of life and limb.

The high-casualty toll and the images of dead Americans dragged through Mogadishu’s streets drove Clinton to call off the hunt for Aidid. On October 13, 1993, he announced that U.S. forces would leave Somalia no later than March 31, 1994. In the announcement, he avoided mention of the botched raid, and instead attributed the decision to plans for transition of the mission to the United Nations. U.S. troops would not leave immediately, he stated, because “were American forces to leave now we would send a message to terrorists and other potential adversaries around the world that they can change our policies by killing our people.” Yet ending the hunt for Aidid and setting a withdrawal date for U.S. forces were changes to America’s policies, ones that future terrorists like Osama bin Laden would cite as evidence of the value of killing Americans.

Somalia returned to the attention of the U.S. national-security community after 9/11, as the result of a decision by bin Laden to dispatch lieutenants to the country. On the run in Pakistan, bin Laden was sprinkling his faithful across Muslim lands to reduce his movement’s vulnerability and diversify its recruiting base. The lack of a viable central government and the presence of Sunni Muslims made Somalia an ideal place to recruit followers, plan terrorist strikes, and hide from the Americans.

In 2006, a Somali-Islamic extremist group known as the Council of Islamic Courts took control of Mogadishu, driving out the feeble provisional government. The Council’s fighters swept into central and southern Somalia and seemed on the verge of consolidating control of the whole country. Neighboring Ethiopia, however, became so alarmed at the prospect of an extremist state on its borders that it unleashed its army. The Ethiopians handily defeated the Council, seizing Mogadishu in just a few days.

For U.S. special-operations forces, Ethiopia’s occupation of Somalia was a windfall. Arriving in Mogadishu together with the Ethiopian forces, American special operators set up shop alongside them. While the Ethiopians secured roads and swatted down lowly insurgents, the Americans nabbed al-Qaeda leaders.

But after the Ethiopians reinstated the provisional government, it remained incapable of governing effectively or organizing large security forces. Al-Shabab, an ascendant offshoot of the Islamic Courts Union, waged a vigorous, effective guerrilla war on the Ethiopian occupation forces, inflicting heavy casualties. To ease the burden on the Ethiopians, the UN Security Council decided in 2007 to deploy 8,000 African Union troops to Somalia for what would come to be known as African Union Mission in Somalia (AMISOM).

In early 2009, Ethiopia negotiated a peace agreement with the Islamists and withdrew its forces. The Ethiopians had scarcely crossed the border when the Somali Islamists breached the peace agreement. UN-trained Somali security forces were supposed to protect the transitional government, but they quickly crumbled once the Ethiopian buttresses had been removed. Extremist forces took control of Mogadishu and most of Somalia’s other territory. Radicals from around the world flocked to Somalia to join in the fun.

According to the FBI, at least 30 Americans joined al-Shabab by 2011, three of whom had carried out suicide attacks against African Union forces. Abdisalan Hussein Ali, a 22-year-old American of Somali extraction who had briefly studied chemistry at the University of Minnesota before disappearing in 2008, recorded a message to inspire future jihadists prior to blowing himself up. “Don’t just sit around, you know, and be, you know, a couch potato and just like, just chill all day,” he said. “Today jihad is what is most important. It’s not important that you become a doctor, or some sort of engineer.”

The withdrawal of Ethiopian forces from Somalia and the rise of al-Shabab greatly reduced U.S. opportunities to hunt down extremists on Somali territory. President Obama was unwilling to establish a military footprint in the country, so intelligence collection had to take place at a distance. Operational forces had to fly in from elsewhere, reducing their stealth advantage. U.S. special operations forces conducted only occasional strikes against terrorist suspects in Somalia.

Like the Islamic Courts Union before them, al-Shabab poked Somalia’s neighbors too hard and in so doing spoiled its own chances of consolidating control. In July 2010, al-Shabab suicide bombers blew themselves up in a rugby club and an Ethiopian restaurant in Kampala, for the purpose of inducing the Ugandans to withdraw their AMISOM troop contingent from Somalia. The blasts killed more than 70 people and injured more than 80. Rather than cowering, the Ugandans took the fight to al-Shabab, sending more troops to Somalia, increasing the size of AMISOM to 20,000. In August 2010, the Ugandans spearheaded an offensive that ousted al-Shabab from Mogadishu.

At this juncture, the U.S. military advocated the insertion of its own personnel into Somalia to train and advise both Somali and African Union forces. The White House turned down the recommendation. With AMISOM lacking enough troops to extend central authority beyond the country’s main urban centers, al-Shabab was able to hang on to much of the countryside.

Al-Shabab lashed out again at its hostile neighbors on September 21, 2013, with the storming the Westgate Mall in Kenya. During the three-day siege, the attackers killed 67 people, including 18 foreigners, and wounded another 200. The Obama administration downplayed the attack in public, but a number of U.S. officials privately voiced great concerns about al-Shabab’s rising power. Some recommended strikes to kill al-Shabab’s leadership. The ability of al-Shabab leaders to mingle with the population, however, discouraged the use of drone strikes, as did the growing international revulsion at drone warfare.

Problems arising from the intermingling of civilians with the enemy also stood in the way of precision-strike missions by U.S. special operations forces. The most valuable targets, moreover, were located in territory held by the enemy, which would afford it greater opportunities to detect and resist raiding forces. In spite of those obstacles, Obama authorized a raid to nab the al-Shabab commander Abdulkadir Mohamed Abdulkadir, whom U.S. intelligence had located in Baraawe, a Somali city of 200,000 residents. At two in the morning on October 5, 2013, a speedboat deposited 20 U.S. Navy SEALs at one of Baraawe’s beaches. When they reached the house where Abdulkadir was believed to be located, a sentry saw them and opened fire with his AK-47. The eruption of gunfire awoke other militants in nearby compounds, who ran toward the sound of the guns, their own assault rifles in hand. The enemy fighters kept the SEALs sufficiently busy to allow Abdulkadir to slip away. With the hostile forces multiplying, the SEAL commander soon ordered his men to withdraw.

Two months later, the White House finally decided to send a small number of troops to Somalia. But the Obama administration’s desire to avoid entanglement limited the deployment to just three U.S. advisers. Such a pittance could help with the occasional raid, but could do nothing to build a viable government and security forces.

Establishing the writ of the central Somalian government across the entire country is the best solution, but today it remains far easier said than done. While the Trump administration’s recent deployment of U.S. troops to Somalia suggests that it is more committed to that endeavor than its predecessor, the most important actors are the Somalis, and it is not clear that the current generation of Somalis will ever be up to the task. In the meantime, the United States will have to rely on risky raids if it wishes to eliminate extremist leaders in areas dominated by Al-Shabab.

That is not to say that such raids are unwarranted. Somalia has harbored extremists who pose direct threats to the United States and its allies, not to mention the fledgling Somalian government. But the anticipated reward of an operation must be very high when the risk of American casualties is so severe, and when the long-term consequences are ephemeral.