This has not been an encouraging month in the fight against the Islamist group known as al-Shabaab. The group launched three deadly and successful attacks yesterday alone — in a town in Kenya, a mosque in the Somali capital of Mogadishu, and on an African Union military base in the country’s strategically important Hiran region.

Perhaps more troublingly, Ethiopian troops abruptly withdrew this week from a base in Halgan, also in Hiran. The withdrawal is at least the third town in the last month that Ethiopian forces have abandoned, though there are rumors they have recently withdrawn from as many as eight. Al-Shabaab quickly occupied Halgan, from where it can menace the entire Hiran region.

Addis Ababa has not confirmed why it left Hiran exposed, but it is likely repositioning its forces to respond to large-scale domestic protests that have rattled the Ethiopian government. The Ethiopian withdrawal is problematic because it adds to the growing strains on the African Union Mission in Somalia (AMISOM), the anti-Shabaab military coalition of which Ethiopia is a member. AMISOM is due to start leaving Somalia in late 2018, but the growing pressure on its members suggests that an even earlier exit is possible. AMISOM’s other major troop-contributing countries — Burundi, Uganda, and Kenya — are all vulnerable to political upheaval of the sort that appears to have Ethiopia contemplating a drawdown.

This should set off alarm bells from Mogadishu to Washington. AMISOM is the only capable ground force battling al-Shabaab, and it is critical to protecting the highly fragile and reversible military gains made against the group. An all-out fracturing of the mission would have dire consequences for the fight to defeat al-Shabaab.

The domestic woes of the most prominent troop-contributing countries vary, but all have the potential to disrupt the AMISOM mission. Burundi, a small country that punches above its weight with its 5,400 soldiers deployed throughout Somalia, remains trapped in a long-simmering domestic political crisis. In response to the Burundian government’s violent handling of pro-democracy demonstrators, the European Union cut $484 million in aid to Burundi in March and threatened to pull another $65 million in annual commitments to the country’s AMISOM contingent. If these threats compel a Burundian withdrawal, or if the Burundian government decides its troops would be more useful at home, AMISOM would suffer a serious blow.

In June, Ugandan President Yoweri Museveni threatened to withdraw his country’s contingent of more than 6,000 troops, which form the backbone of AMISOM. While he has since walked back the threat, Museveni’s recent ambivalence toward AMISOM is likely driven by frustration with a costly commitment, particularly in the face of the slow and as yet unsuccessful building of competent Somali security services. Museveni is likely uninclined to leave AMISOM at present because he wishes to maintain his position as a regional power broker. Yet without progress in the Somali security sector, he may come to believe Uganda’s participation is untenable.

Problems at home could force the decision upon him, as well. Dozens of military officers were arrested in June for allegedly plotting a coup. Senior Ugandan officers also disapprove of Museveni’s apparent attempts to position his son, Maj. Gen. Muhoozi Kainerugaba, as his successor. Such fractiousness within the military is worrisome for the stability of AMISOM.

Kenya, which contributes about 3,500 troops to AMISOM, may have a larger stake in the Somali political order than most other countries in this coalition. Kenya has suffered repeated al-Shabaab terrorist attacks inside its borders, and its longstanding plan to repatriate hundreds of thousands of Somali refugees relies on a semblance of stability in southern Somalia. The Kenyan military is also accused of making millions of dollars by smuggling sugar and charcoal through Somalia’s port of Kismayo, which it controls and is likely keen to hold on to.

Yet the heavy casualties Kenya is suffering and the government’s reluctance to be forthright about them have stirred domestic discontent. Public support for the Somalia venture has fallen significantly over the last five years, and the political opposition has already called for a withdrawal. The government itself regularly threatens to leave AMISOM, though such threats are probably designed only to wheedle more support from the international community. No matter the government’s sincerity, if current trends continue, it will soon be hard-pressed to defend the Somalia mission to a disillusioned public.

Serious funding shortfalls have also contributed to the recent string of challenges AMISOM is experiencing, and there are signs of donor fatigue. Citing “competing priorities,” the European Union earlier this year cut 20 percent of its funding for AMISOM soldier salaries. It was not until September that the African Union could secure back payment of salaries and other operational expenses. Payments expire altogether in May 2017.

Furthermore, paperwork errors have been delaying the disbursement of troop salaries by up to six months, which threatens to torpedo morale in an already difficult environment. Highlighting this risk is a report that AMISOM and Somali soldiers in June abandoned a town — which al-Shabaab promptly reoccupied — possibly to protest the nonpayment to Somali troops.

AMISOM has suffered some terrible defeats over the last year, but it is still al-Shabaab’s most effective opponent. The terrorist group at one point controlled about a third of Somalia, including most of Mogadishu, and it was AMISOM that pushed it from its most important strongholds over the last five years. The pace of territory being liberated from al-Shabaab has greatly slowed, but when a town is freed, AMISOM is still usually at the tip of the spear.

The international community has little leverage over troop-contributing countries’ domestic politics, but there are ways to shore AMISOM up. Pushing for Somali government reforms that will create a path for the coalition to wind down its commitment in a responsible manner is a good place to start. These should include demanding the government create and implement a comprehensive security plan with measurable benchmarks of progress, thus reassuring AMISOM members that there is a realistic end in sight to their costly investment in Somalia. The United States should continue its training of Somali commandos, who have proven effective, but it should also concentrate on buttressing the deeply inadequate security institutions and infrastructure necessary to ensuring the Somali National Army is sustainable and professional.

The United States and the rest of the international community must also resist the urge to throw good money after bad in Somalia. If U.S.-funded programs are not delivering results, they should end. In 2015 alone, the United States spent more than $200 million on humanitarian aid, $320 million on security assistance and security sector reform, and another $1 billion on indirect support to AMISOM. U.S. special operations forces have cooperated with AMISOM and Somali troops for more than a decade to conduct ground raids and drone strikes. But Washington must demand — and enforce — that recipients of aid and training achieve certain benchmarks of progress to continue receiving funding, to prevent the money being pumped into Somalia from fueling corruption and violent competition.

Both AMISOM and Somali forces remain locked in a fierce struggle with al-Shabaab in key areas of the country, with small towns and military bases intermittently changing hands. Al-Shabaab remains a dangerous, committed terror organization, and it is in the interests of many countries, including the United States, to defeat it. Yet the most effective military force fighting al-Shabaab is showing cracks that require swift, smart solutions, lest they result in permanent fractures.

Joshua Meservey (Policy Analyst, Africa and the Middle East at the Heritage Foundation) lived in Africa as an aid worker for more than 5 years, including in East Africa from 2009-2011. He was recently in Nairobi and Mogadishu, and has written extensively on al-Shabaab and Somalia. He is on Twitter at @JMeservey. Kelsey Lilley is Associate Director of the Atlantic Council’s Africa Center and lived in Ethiopia from 2012 to 2013. She tweets @KelseyDegen.