Somalia has been without an effective central government since President Siad Barre was overthrown in 1991.
Years of fighting between rival warlords and an inability to deal with famine and disease have led to the deaths of up to one million people.
Comprised of a former British protectorate and an Italian colony, Somalia was created in 1960 when the two territories merged. Since then its development has been slow. Relations with neighbours have been soured by its territorial claims on Somali-inhabited areas of Ethiopia, Kenya and Djibouti.
In 1970 Mr Barre proclaimed a socialist state, paving the way for close relations with the USSR. In 1977, with the help of Soviet arms, Somalia attempted to seize the Ogaden region of Ethiopia, but was defeated thanks to Soviet and Cuban backing for Ethiopia, which had turned Marxist.
In 1991 President Barre was overthrown by opposing clans. But they failed to agree on a replacement and plunged the country into lawlessness and clan warfare.
Continue reading the main story
At a glance
Scene of Africa's worst humanitarian crisis: aid agencies warn that millions face starvation
No effective government since 1991
Islamist militia and UN-backed transitional government compete for control of country
The self-proclaimed state of Somaliland and the region of Puntland run their own affairs
In 2000 clan elders and other senior figures appointed Abdulkassim Salat Hassan president at a conference in Djibouti. A transitional government was set up, with the aim of reconciling warring militias.
But as its mandate drew to a close, the administration had made little progress in uniting the country.
In 2004, after protracted talks in Kenya, the main warlords and politicians signed a deal to set up a new parliament, which later appointed a president.
The fledgling administration, the 14th attempt to establish a government since 1991, has faced a formidable task in bringing reconciliation to a country divided into clan fiefdoms.
Its authority was further compromised in 2006 by the rise of Islamists who gained control of much of the south, including the capital, after their militias kicked out the warlords who had ruled the roost for 15 years.
With the backing of Ethiopian troops, forces loyal to the interim administration seized control from the Islamists at the end of 2006.
Islamist insurgents – including the Al-Shabab group, which later declared allegiance to al-Qaeda – fought back against the government and Ethiopian forces, regaining control of most of southern Somalia by late 2008.
Ethiopia pulled its troops out in January 2009. Soon after, Al-Shabab fighters took control of Baidoa, formerly a key stronghold of the transitional government.
Somalia's parliament met in neighbouring Djibouti in late January and swore in 149 new members from the main opposition movement, the Alliance for the Re-Liberation of Somalia.
The parliament also extended the mandate of the transitional federal government for another two years, and installed moderate Islamist Sheikh Sharif Sheikh Ahmad as the new president.
However, the government's military position weakened further, and in May 2009 Islamist insurgents launched an attack on Mogadishu, prompting President Ahmad to appeal for help from abroad.
Al-Shabab appears to have consolidated its position as the most powerful insurgent group by driving its main rival, Hizbul Islam, out of the southern port city of Kismayo in October 2009. Since then they have openly declared their alliance with al-Qaeda and have been steadily moving forces up towards Mogadishu.
The long-standing absence of authority in the country has led to Somali pirates becoming a major threat to international shipping in the area, and has prompted Nato to take the lead in an anti-piracy operation.
In 2011, the plight of the Somali people was exacerbated by the worst drought in six decades, which left millions of people on the verge of starvation and caused tens of thousands to flee to Kenya and Ethiopia in search of food.
After the collapse of the Siad Barre regime in 1991, the north-west part of Somalia unilaterally declared itself the independent Republic of Somaliland. The territory, whose independence is not recognised by international bodies, has enjoyed relative stability.