Somalia was without a formal parliament for more than two decades after the overthrow of President Siad Barre in 1991.
Years of anarchy followed the downfall of President Barre, and it was not until 2012, when a new internationally-backed government was installed, that the country began to enjoy a measure of stability once more.
The decades of fighting between rival warlords meant that the country was ill-equipped to deal with natural disasters such as drought, and around half a million people died in the Somali famines of 1992 and 2010-12.
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.
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, faced a formidable task in its efforts to bring 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 and in 2012 announced its merger with the global Islamist terrorist group - 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.
Foreign intervention in Somalia
1992 - UN troops arrive to monitor ceasefire after fighting which followed fall of Siad Barre. US-led task force delivers aid
1993 - UN mission is dealt a fatal blow when US rangers are killed in incident made famous by Hollywood film Black Hawk Down
1995 - UN troops withdraw, leaving warlords to fight on. UN casualties number 150
2006 - Ethiopia sends troops to defend interim government
2007 - African peacekeeping force AMISOM deploys
2011 - Kenya enters Somalia in pursuit of al-Shabab militia
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 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.
But al-Shabab was wrongfooted by a series of government and African peacekeeper offensives and a Kenyan army incursion in 2011. They withdrew from Mogadishu in August 2011, the port of Baidoa in February, the key town of Afgoye in May and the port of Merca in August, and lost their last urban stronghold - the major southern port of Kismayo - in October 2012, along with the major inland town of Wanla Weyn.
In a sign of growing confidence, Somalia's first formal parliament in more than 20 years was sworn in at Mogadishu airport, marking an end to the eight-year transitional period.
The long-standing absence of authority in the country led to Somali pirates becoming a major threat to international shipping in the area, and prompted Nato to take the lead in an anti-piracy operation. International efforts were seen to bear fruit in 2012, when pirate attacks dropped sharply.
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.