Somalia has been without arecognised central government since 1991, when President Mohamed Siad Barre was overthrown.
The country has since splintered under the control of various groups, including transitional federal institutions and the Islamic Courts Union, which at one point controlled much of south and central Somalia. There are also the breakaway states of Somaliland, Puntland and Jubaland.
Successive international interventions, including the African Union mission in Somalia, Kenyan and Ethiopian armed forces, and the most recent United Nations assistance mission in Somalia, deployed in July, have all failed to contain the security situation in the country.
Many blame international involvement, including the United States, for exacerbating the situation by picking sides in the conflict and pitting factions against each other.
The rise of al-Shabab – an al-Qaeda-inspired group that emerged from the courts movement in retaliation against what was seen as the unwarranted interference of foreign powers in Somalia's affairs – has brought an increasingly unpredictable element to the conflict.
Kenya, which has suffered a series of attacks building up to the events at Westgate as a result of its involvement in Somalia, sent troops into the country in October 2011 to fight al-Shabab, vowing to pull them out by Christmas.
Yet the group remains a bold symbol of the intransigent nature of Somalia's security problems.
Since 2010, when Mogadishu was the scene of bloody urban warfare, there have been signs of recovery, with a growing number of Somalis from the diaspora returning to the country and a mini property boom in the capital, Mogadishu.
But some analysts say that, as al-Shabab has lost its stronghold over parts of the country, it has become an increasingly desperate movement, posing a greater security threat than ever.
"Al-Shabab has lost a lot of territory," said Rashd Abdi, a Somalia expert in Nairobi. "It is an increasingly diminished movement; it has alienated many Somalis.
"To make up for those losses, [al-Shabab] has stepped up its asymmetric warfare tactics. Mogadishu is now more unsafe – with bombings, assassinations, grenade attacks, and now seeing this [the Westgate mall attack] [it has] become regionalised.
"My fear is that it may also become internationalised – al-Shabab supporters around the globe may want to launch an attack like this." – © Guardian News & Media 2013