MOGADISHU, Somalia — Street stalls sell piles of plump mangoes and stacks of freshly baked bread, a bookseller has set up shop on sheets of newspaper laid on the ground. Sidewalk cafes offer cups of sweet tea beneath shady trees, freshly painted murals on shopfronts depict items for sale: watches, computers, mobile phones.

A work team plasters over bullet holes and slaps a new coat of whitewash on an old wall. The K4 roundabout at this city’s heart has been repainted in pastel pink and sky blue. Donkey carts, minibus taxis, cars and 4x4s clog the road, horns beep, drivers shout.

Watching this hectic scene by the roadside stand two children, arms around each other’s shoulders, eating ice lollies.

A little further up the road, at a place that two years ago was a frontline position, kids chase each other around abandoned sandbags.

There are still plenty of armed men around but almost all now have uniforms.

This is a different Mogadishu than in recent years. The city has been slowly coming back to life since August when African Union soldiers pushed Islamist insurgents from the city center ushering in a peace not seen since 2006 when the grassroots Islamic Courts Union briefly held power.

“The time of the Islamic Courts was a gift from Allah: It couldn’t last,” said Ali Guled, a truck driver. “But the Shabaab that came after was the worst time in all Somali history so at least now we have some peace.”

The frontlines are now miles from the center of this damaged seaside capital of 2 million. Al Shabaab, an ally of Al Qaeda, and which has a penchant for brutal Shariah law punishments, is on the backfoot but is not yet defeated.

“Security in Mogadishu is volatile. We face harassment everyday from the Shabaab,” said Col. Oscar Nzohabonimana, commander of the 4,500-strong Burundi contingent of the African Union Mission in Somalia (AMISOM).

“The area is vast and it is difficult to control all of it.”

More from GlobalPost: Al Shabaab changes name, not tactics

At the western frontline, in a suburb called Deyniile where the city fades into the countryside, there are still daily exchanges of fire but they are brief and rarely deadly.

“There is a changing face to how the Shabaab operate. They are no longer holding ground so their options are hit-and-run, [roadside bombs], suicide attacks,” said Brig. Paul Lokech, commander of AMISOM’s 5,200 Ugandan soldiers.

These attacks have grown more frequent since Al Shabaab's withdrawal. A truck bomb in October killed at least 70 people making it the most deadly such attack in Somali history. Earlier this month there were as many as 15 explosions in just two days, some killing, some maiming and all spreading fear.

Wafula Wamunyinyi, a senior civilian official with AMISOM, described the gains made in Mogadishu as “fragile.”

“The [security] improvements we have achieved are only in Mogadishu, and even on the outskirts Shabaab is there. And in the whole country, everywhere else they are controlling all the small towns and cities in Somalia,” said Wamunyinyi.

“Removing Shabaab from Mogadishu has posed new challenges of a different kind of warfare that is not a real fight. But IEDs [improvised explosive devices], targeted killings, they are on the rise,” he said.

Nevertheless, the African Union soldiers have achieved something that 22,000 US and UN troops failed to do in the early 1990s: They have pacified Mogadishu. Earlier this year the Transitional Federal Government (TFG) was rightly described as controlling just a few blocks of the city, now its influence reaches across 90 percent of the capital.

It has come at a cost. The loss of 18 US soldiers in 1993 during a battle recounted in the book and film "Black Hawk Down" was enough to trigger a US — and then UN — withdrawal from Mogadishu.

AMISOM has stayed despite losing around 500 soldiers since troops were first deployed in 2007, and seeing some of them dragged through Mogadishu's streets and their bodies publicly displayed and posted on websites.

“It has taken a huge sacrifice from AMISOM fighters, we have had many casualties,” said Wamunyinyi.

Outside Mogadishu, Al Shabaab is facing attacks on two more fronts. Kenya invaded from the south in October and Ethiopia from the west in November.

Many in the government and the AU would like to see the force expanded from a mandated strength of 12,000 to 20,000 and be redesignated as a UN peacekeeping mission, or a hybrid as in Darfur, allowing other countries to send troops.

But so far the regional approach seems to be working, offering a rare example of the much-touted “African solutions for African problems.”

“Solving Somalia’s problems required regional intervention,” said Lokech, the Ugandan commander. “I don’t know when the UN will come but this regional intervention is working.”

Related: Al Shabaab claims to have killed dozens of African Union peacekeepers

Whether it is sustainable is another question. Few doubt that if AMISOM pulled out tomorrow the TFG would collapse under the weight of political infighting, military incompetence and fragmentation.

What passes for the Somali army is a combination of militiamen loyal to their clan leaders, rather than the state, and officers who served under the last government before 1991 and should be retired.

“We are trying to rebuild the army but even those we have trained the moment they leave the barracks they fall back to their clans. And we still have warlords. And some of those within the government, even as we think we are rebuilding, their loyalties are elsewhere,” said Wamunyinyi, the AMISOM offical.

But Lokech is more forgiving. His troops are billeted alongside government troops at the eastern frontline in Huriwa district. Together they man the trenches that snake through abandoned villas and overgrown gardens, warily eyeing the road ahead and taking shots at whoever they see.

“The TFG is a young force, you don’t need to judge them now," said Lokech. "We are mentoring them, and with time you will be able to bank on them.”

More from GlobalPost: Inside Somalia