‘We cannot just die here,” Siida’s husband told her. Mohammed stood at the doorway of what remained of their five-bedroom house in Somalia’s capital, Mogadishu, their three eldest children at his side. “If I don’t come back let us forgive each other. You must take care of the rest of the family.”

Inside the crumbling house, three-year-old Nimo, the couple’s youngest child, was wailing. Mohammed turned and walked down the street, determined to take his three teenage children to school.

The fighting in Mogadishu had been particularly fierce during the past few weeks. Siida and Mohammed had stayed in the city throughout all the previous wars that had battered the once-beautiful seaside capital over the past two decades. It had never been as bad as this, though. Their house had been hit by mortars and bullets. One night uniformed fighters – Siida didn’t know from which faction – had come to their house and stolen everything they owned. “Even my scarf,” she recalled. Her younger sister was raped; her children were terrorised.

The morning Mohammed left to take the children to school the fighting was on their street. Within hours Siida realised it wasn’t safe enough to stay. She gathered her seven remaining children and left Mogadishu. The journey here to Hargeisa, the dusty capital of Somaliland, where thousands of refugees live in the shadow of the old governor’s mansion, was perilous. Armed bandits ambushed her group in Beled Weyne, a town north of Mogadishu. They raped some of the women, sparing Siida because she was a mother.

For most of Siida’s life, Somalia has been in a state of violent flux. The last functioning central government, the military regime of Mohamed Siad Barre, was overthrown in 1991. Numerous attempts to form a fresh government have failed as rival warlords factions, divided by clan, have fought for control.

But in recent years Somalia’s wars have taken on an international dimension. The previous US administration believed terrorist suspects were living in Somalia, protected by local Islamist groups. The CIA funded a handful of warlords, hoping they would capture the suspects. Instead it set off a series of events which have turned Somalia into a crucible in the war on terror – a country where both the US and al Qaeda believe it is vital they gain influence.

The Bush administration’s fear of al Qaeda threats – real and make-believe – led it to destroy Somalia’s best chance for peace. A loose coalition of Islamist groups, known as the Union of Islamic Courts (UIC), took control of Mogadishu in 2006, ousting the last of the US-backed warlords. They brought a semblance of peace and security to the city that Somalis hadn’t experienced in nearly two decades.

There were disagreements within the UIC between the moderate leaders like Sheikh Sharif Sheikh Ahmed, who simply wanted to bring law and order to the country, and the more extreme leaders like Shiekh Saan Dahir Aweys, who wanted to build a greater Somalia, annexing parts of Ethiopia and Kenya.

The US, encouraged by Ethiopia, focused on the extremists. President Bush’s top African diplomat, Jendayi Frazer, accused the UIC of being run by an “east Africa al Qaeda cell”.

With the tacit approval of the US, Ethiopia invaded Somalia in December 2006, swiftly ousting the UIC and installing a transitional government, led by the septugenarian former warlord, Abdullahi Yusuf.

The initial success didn’t last. The UIC’s military wing, Al Shabaab, began an insurgency, targeting Ethiopian and Somali government troops.

More than a ­million people, out of a population of around seven million, were forced to flee from their homes as both sides indiscriminately shelled civilian areas. Tens of thousands were killed.

Optimists, who number few in Somalia, hoped that Ethiopia’s withdrawal at the start of 2009, coupled with Yusuf’s resignation, could herald a more peaceful era. The Shabaab, who said they were fighting to oust the Ethiopians, could claim a victory, while a more moderate president could develop an inclusive peace process.

The man who would become president, elected at a specially convened conference in neighbouring Djibouti, was a familiar figure: Sheikh Sharif Sheikh Ahmed, one-time chairman of the Islamic Courts, the organisation Bush officials had claimed were linked to al Qaeda.

By now, the rift between Sheikh Sharif, a softly-spoken former geography teacher, and his former mentor, Sheikh Aweys, had become a chasm. Aweys accused Sharif of being an American puppet. Al Shabaab and Aweys’s new coalition, Hizbul Islamia, vowed to overthrow him.

The fighting in Mogadishu which forced Siida and her children to finally flee began in early May. Shabaab fighters came within half a mile of Sheikh Sharif’s presidential palace. Western intelligence officials in neighbouring Nairobi worried that the government would fall. To bolster Sheikh Sharif the US shipped 40 tonnes of light weapons to Mogadishu. French security agents were dispatched to train the new government’s weak armed forces.

Experts now believe the fighting has reached something of a stalemate. Politically, Sheikh Sharif has taken some of the sting out of the Shabaab’s campaign by introducing a form of sharia law, one of their main demands.

The Shabaab is also struggling to control the areas it has already captured. The group’s often disparate factions have offered different styles of governing, some preferring modest sharia law, while others have gone for a more extreme – some would say un-Somali – version.

In a part of northern Mogadishu, four young men had their right hands and left legs amputated in a public ceremony after allegedly committing a robbery. Gangs of men in the southern town of Merka have been roaming the streets with pliers, pulling gold and silver teeth out of people’s mouths, alleging that they are “un-Islamic”.

The more extreme versions of sharia have not been supported by the population. In some areas there are reports that Shabaab has had to post guards at the edge of its territory to prevent civilians escaping.

The splits within Al Shabaab are reflected in its dealings with aid agencies. Some Shabaab administrations have been willing to allow agencies into their areas to deliver aid, while other factions have thrown them out of the territory they control. Unicef last week warned that increasing hostility to aid agencies was putting more than 850,000 children at risk because it wasn’t possible to get essential supplies to them.

The humanitarian situation remains one of the worst in the world. More than three million people – almost half the population – is in need of emergency aid, but agencies are struggling to get access. Eight aid workers have been killed since the start of the year.

The 15-mile road between Mogadishu and the small town of Afgooye – known as the Afgooye corridor – is now home to almost half a million people living in ragged tents or sleeping under trees. The crisis threatens to get worse as drought sweeps across central and northern Somalia.

Abdullahi Yusuf, Oxfam’s country director for Somalia, said: “After 18 years of fighting and suffering, enough is enough. Ensuring that millions of Somalis receive desperately needed emergency assistance must be the absolute priority of the international community.”

For the United States, though, the biggest fear is al Qaeda. Al Shabaab has been designated a terrorist organisation by the US and it claims to have strong links with al Qaeda. More than 100 foreign fighters have moved to Somalia to join forces with the Shabaab.

President Obama may have a domestic policy problem if Mogadishu falls to an Islamist group linked to al Qaeda, said Professor Ken Menkhaus, a US-based Somalia expert. “Conservative American pundits will have ample fodder to portray Obama as weak on terrorism,” he wrote in Foreign Policy magazine.

Some regional analysts worry that the fear of being the first American president to “lose a country” to al Qaeda could lead President Obama to consider air strikes from unmanned drones similar to those carried out in Pakistan and Afghanistan. Such a move would play into the hands of Shiekh Sharif’s opponents, Menkhaus warned.

In truth, Somali jihadists don’t need to control Mogadishu to cause damage. Extremist imams in Kenya are already reported to be trying to recruit young, unemployed men. Western embassy officials have been warned to stay away from some of Nairobi’s upmarket

shopping malls.

Solutions for Somalia imposed by outsiders have never worked before and show no sign of working now. It was the US’s determination to oust the Islamic Courts which gave birth to the more extreme Al Shabaab movement. “What was essentially a splinter, an annoying but small minority of jihadists, is now a super-charged minority of trouble-makers,” said one Nairobi-based analyst who wished to remain anonymous. “The international community helped empower them through their connivance in getting out the Islamic Courts. This was going to happen, and it has happened. It’s so frustrating.”

The US shipment of weapons may have helped Sheikh Sharif’s government regroup but it has also bolstered the warlords within his regime who have spent the past 20 years ripping the country to shreds.

There are also rumours that some of the weapons have been sold off in Mogadishu’s infamous Bakara market and are now in the hands of Shabaab fighters. “We never get it right,” said the analyst.

Adjusting to her new home in Hargeisa, Siida knows it will be a long time before she can return to ­Mogadishu. She has yet to hear whether her husband and their three eldest ­children are alive or dead. “I am just in the dark,” she said.

Thousands of refugees from a handful of Somali conflicts over the past 20 years now live in this makeshift camp at State House, the old governor’s mansion in Hargeisa. Homes are made out of dirty sheets, rags and rusted corrugated iron. Thorny acacia branches sprout out of the dusty ground.

Siida is relatively lucky. One of the leaders of the camp, a doughty woman called Kos Dahir, has helped find her a room and has taken four of Siida’s children to live with her. “I saw her with all these children,” Kos said. “One on her chest, one on her back, holding others by the hand. It reminded me of when I became a refugee.”

The room has a mattress, a cracked mirror and a mosquito net. Nimo, Siida’s youngest child, sits on her lap playing with an old pipe. “We are still alive inside,” she said.