After dark, the dull thud of mortars and the staccato popping of machine guns come more frequently. Sometimes the explosions make it hard to sleep, so I lie awake counting, learning to read the Mogadishu soundscape: one . . . two-three . . . four. Pauses follow sequences of explosions like Morse code, each bullet and mortar landing somewhere, ending or ruining a life.
The fighting is sporadic, but suffering and death strike frequently and at random. At an outpatient clinic one Monday afternoon in January, an 82mm mortar hits the queue waiting outside. Seven-year-old Muhammad is on his way to see his mother, a cleaner at the clinic, when the exploding mortar peppers his left side with shrapnel. Six other people are blown to pieces. In hospital hours later, the geometric white patches scattered across the curves and shades of an X-ray show where the shards have embedded themselves in Muhammad's body.
The current round of fighting is just the latest in Somalia's decades-old war. Al-Shabaab, an Islamist militia that recently confirmed its allegiance to al-Qaeda, is battling the Transitional Federal Government for control of the country. The TFG gets diplomatic support and money from the UN, soldiers from the African Union and military hardware from the US; take any one of these away and it would collapse like every other administration in the past 19 years. In 1991, the country's last functioning government - itself a venal dictatorship - was defeated by an alliance of clan militias. The warlords then turned on each other, fighting for economic and political control. Somalia has been a maelstrom of violence ever since.
There have been moments of respite. In 2006, the militias were defeated by the Islamic Courts Union - a political group of which al-Shabaab was the armed wing. But within months the union had been chased from power by a US-backed Ethiopian invasion.Now, al-Shabaab is back - stronger and more radical - and holds sway over much of Somalia. Mogadishu is a city of ruins, bearing testimony to the years of destruction. Roads are broken; buildings are shattered, concertinaed to the ground or lacking outer walls, like giant honeycombs. Battered minibus taxis move aside for armoured personnel carriers and "technicals": home-made Somali battle wagons constructed by welding machine guns on to pickup trucks. In street battles, gunmen use these to blast the hell out of each other and anyone in between.
But here and there are echoes of a lost grandeur. Down by the sea, there is an old city quarter of once-paved piazzas lined with roofless porticos, crumbling façades and ornate cracked archways. Dust devils twist down sun-bleached streets past groups of men drinking sweet tea. They wear loose short-sleeved shirts and macawis - printed cotton sarongs. Some cradle AK-47s in their laps. Women in niqabs hurry by, robes flapping in the wind.
At a crossroads known as K4, beneath a clear blue sky, a dozen or so soldiers sweat. They are members of the 5,300-strong Ugandan and Burundian peacekeeping force deployed by the African Union Mission in Somalia (AMISOM). K4 is on a major route between the port and the airport, and the soldiers face almost constant fire from the nearby Bakara Market, an al-Shabaab stronghold.
Sometimes they fire back with mortars. They say they try to limit "collateral damage", but Bakara is a densely populated neighbourhood and a mortar is an indiscriminate weapon. Bullets smack into concrete walls overhead or thud into the sandbags piled high around the rooftop of the old Egyptian embassy building where the peacekeepers are stationed. "Since morning we have been under attack from sniper fire," says the detachment's Ugandan commander.
A few days later, on 29 January, President Sheikh Sharif Ahmed is due to celebrate one year in power. At two that morning, al-Shabaab attacks, firing the first shots at K4. Tank fire reverberates around the city; the fighting that
follows is the heaviest Mogadishu has suffered in months.
By late morning gunshots are still ringing out; but at Villa Somalia, the president's hilltop palace, government supporters are determined to have their anniversary party. Ahmed, a diminutive figure at the best of times, sits lost in the puffy folds of an outsized leather armchair, watching a wobbly documentary of his achievements projected on to a white wall.
He barely blinks when the first mortar hits a checkpoint on the edge of the sprawling palace grounds, killing one and wounding at least three. The second mortar is closer, landing just metres from the hall where hundreds are gathered to hear poets and choirs sing the president's praises. Panic starts to spread as dust and smoke leak through the latticework walls of the building. Then tanks fire back in the direction of the attack and there are no more mortars. The crowd resettles and the performers continue.
Assaults on "safe" parts of Mogadishu - Villa Somalia or the AMISOM headquarters, struck by suicide bombers last September - underline the weakness of the government's grip on even the few parts of the city it claims to control. With neither the TFG nor its enemies strong enough to inflict an outright defeat on the other, the city has fallen into a deadly impasse. A much-discussed government/AMISOM offensive against al-Shabaab may break the deadlock. But fighting has never yet brought peace to the residents of Mogadishu.