Over the last eleven years, the once makeshift military base at the end of the runway at the Mogadishu airport has turned into a bustling mini town. Sandwiched between concrete barriers and a jagged coastline, the base hosts scores of recently returned diplomats, aid workers, and United Nations staff members, along with thousands of African Union peacekeepers. When I visited the compound in 2010, I received a jerry can of water to wash with and a cot. Now, international-security companies run hotels that serve fresh lobster and chilled white wine. Diplomats jog along the beach that lines the camp, but in a sign of lingering safety concerns, they rarely venture into Mogadishu city itself.

In Mogadishu’s markets, parks, and beaches there is a sense of security not known here for decades, and the government of Somalia largely credits the United States and the African Union with providing it. The Trump Administration has increased American military involvement in Somalia to levels not seen since eighteen American soldiers were killed by clan militias in the 1993 clashes depicted in the film “Black Hawk Down.” The number of American troops on the ground doubled last year, to over five hundred, and air strikes increased to thirty-four in 2017, double the number that took place in 2016.

The U.S. military is fighting a shadow war with Al Shabaab, an Al Qaeda-aligned Islamist group that still controls large swathes of Somalia. American forces are operating from remote, rural bases and striking deep inside Al Shabaab-controlled territory. Somali officials say that the Special Forces raids and drone strikes targeting the group’s leadership have had significant impact. Al Shabaab fighters are now on the run in many areas and unable to seriously threaten the Somali government’s hold on the capital city of two and a half million people, as well as other large towns. But it is unclear how long that security will last.

After a decade of effort here, the twenty-one thousand African Union ground troops that secure Mogadishu are preparing to leave the country by 2020 and hand over security to an estimated eight to ten thousand poorly equipped Somali soldiers and police. “We can’t stay here forever, and we have not planned to stay here forever,” Ambassador Francisco Caetano Madeira, the African Union’s Special Representative to Somalia, told me. “And we are not the Somali National Army.”

Madeira said that if a decision is made to keep some African Union forces in Somalia, more funding must be provided by the international community. The European Union, which provides much of the funding for the A.U.’s mission in Somalia, cut its contributions in 2016 by twenty per cent. “This is a very expensive war, you know, counter-insurgency, counterterrorism, is perhaps much more expensive than conventional warfare,” Madeira said.

While Al Shabaab has been degraded by the American military, it can still strike the center of Mogadishu. Suicide-bombing campaigns have gained intensity, and in October of 2017, a massive truck bomb killed more than five hundred people. Yet the city’s beaches are packed most days with residents eating in restaurants or at local stalls that sell snacks. Small boats bearing Somali flags take women out for rides, navigating through the crowd of swimmers. Bullet-riddled shop walls have been repaired and covered with bright, hand-painted images of what’s for sale, everything from bottles of bleach to corn on the cob, printing paper, and chicken drumsticks.

The relative stability of the capital is primarily the result of a grinding, decade-long campaign by African Union soldiers, mostly from Uganda, to gradually retake control of the city. When they arrived in Mogadishu, in 2007, gangs of Al Shabaab fighters controlled much of the city. A.U. troops established a base in Mogadishu’s southern suburbs and attempted to protect a Western-backed transitional government. In reality, they only controlled a handful of embattled city blocks and a Presidential palace under siege. In 2011, A.U. forces launched an offensive that pushed Al Shabaab fighters out of the city, but fighting continued in pockets, and the Islamists’ presence on the outskirts of the city continued to threaten the capital. In rural areas, between 2014 and 2016, the group overran several African Union military bases. The A.U. has never released casualty figures, but estimates run to several thousand.

Building on the A.U.’s success, the Obama Administration launched a drone-strike campaign in Somalia in 2011. Last summer, the Trump Administration expanded those operations. African Union commanders say that the American drone strikes have restricted the movements of Al Shabaab fighters. A group that once stood and fought them ferociously is more cautious with American drones in the skies. Brigadier Paul Lokech, the commander of all African Union forces in Mogadishu, told me that the presence of American drones in Somalia has made A.U. forces more effective. “If it is there, that means you solve the problem faster,” he said.

Lokech, an officer in the Ugandan Army, commanded African Union troops during the 2011 offensive that pushed Al Shabaab out of the capital, earning him the nickname the Lion of Mogadishu. Six feet six inches tall, he returned to Mogadishu in December to command troops in the capital for a second time. When I asked him about the American military presence, Lokech chose his words carefully. “They are not within the AMISOM chain of command, but we coördinate,” he said, using the acronym for the African Union Mission in Somalia. “They are friendly forces; they are allies. We talk to one another.” (American military officials did not respond to a request for comment regarding U.S. operations in Somalia.)

Somali government officials have hailed American forces and say that they would welcome even greater U.S. military involvement. Abdirahman Omar Osman, the Somali information minister, told me that his government wants more drone strikes. He also said that he expects the U.S. military to help plan, unofficially, an upcoming offensive by African Union and Somali forces against Al Shabaab, and help advancing troops by softening up target areas with drone strikes beforehand.

Training Somalia’s Army to operate on its own has been a struggle. Regional political divisions and rifts between clans have slowed efforts to reach a consensus on how the country’s security institutions should be structured. Corruption is endemic. In December, the U.S. suspended aid to some of Somalia’s security forces because graft was so pervasive. Community leaders told me that they are confused about why the United States is not facilitating peace talks between warring clans, a central cause of the country’s continued instability. They say Al Shabaab exploits this chaos by offering protection to vulnerable, weaker clans.

“Americans control the air. And you don’t have people in the air. The people are on the ground,” Sultan Hajja Abdullah, an elder in the Bimal clan, told me. He said that he wanted the American officials to talk to community leaders like himself. “Yes, we appreciate that the Americans are killing the Al Shabaab leaders, destroying their bases. But what the Americans were supposed to do is to reconcile the clans.”

Across Mogadishu, clan leaders and residents also whisper about growing numbers of civilian casualties in U.S. drone strikes. The exact number of deaths is unknown—Al Shabaab ban smartphones that have cameras in the areas they control—so images of civilian casualties from drone strikes are rare. Last year, the Trump Administration relaxed the rules of engagement for the U.S. military’s Africa Command that the Obama Administration had put in place to minimize civilian casualties.