A feud between Somalia's president and prime minister has plunged the country into a damaging crisis as it battles an Islamist insurgency.
Somalia has been mired in chaos since the fall of its military regime in 1991. Civil war and clan warfare followed, before the rise of the Al-Qaeda-linked Al-Shabaab.
This is a timeline of the main events since 2011:
2011: Al-Shabaab driven from capital
Al-Shabaab are driven out of the capital Mogadishu in 2011 by an African Union force.
But they retain control of vast swathes of the countryside from which they launch deadly attacks across Somalia and abroad. Thousands have been killed in the ongoing violence.
2012: New parliament
A national parliament is formed in 2012 after the adoption of a provisional constitution. It elects Hassan Sheikh Mohamud as president.
2013: Kenya Westgate attack
Al-Shabaab claims responsibility for an 80-hour siege at Nairobi's Westgate shopping mall in 2013, which leaves at least 67 people dead. The militants say it was retaliation for Kenya's military intervention in Somalia.
2015: University massacre
Two years later Al-Shabaab gunmen storm Garissa University in eastern Kenya, killing 148 people -- mostly students.
2017: Clan polls
Somalia has not held a one-person, one-vote election in 50 years. Instead thousands of special delegates chosen by Somalia's myriad clan elders pick parliamentary representatives.
In 2017, these MPs and senators elect Mohamed Abdullahi Mohamed -- best known by his nickname Farmajo -- as president. No Somali president has ever won a second term in office.
In 2017 Washington extends the powers given to US troops, who have been stationed in the country since 2007, to carry out strikes on Al-Shabaab.
In October that year a truck packed with explosives blows up in a bustling commercial district in Mogadishu, killing 512 people and injuring 295, in the deadliest attack blamed on Al-Shabaab.
2020: Election discord
Prime Minister Hassan Ali Khaire falls to a no-confidence vote in July 2020, officially for having failed to organise elections by universal suffrage.
Two months later Mohamed Hussein Roble is appointed in his place and a new election timetable is cobbled together.
Outgoing US president Donald Trump orders the withdrawal of most American troops from Somalia by early 2021.
2021: Political crisis
The election pact between the central government and regional states collapses and Farmajo's presidential term expires before fresh elections are held, sparking a constitutional crisis.
An alliance of opposition candidates declares the president illegitimate and demand he resign.
In April Farmajo's mandate is extended by parliament, setting off deadly gun battles in the streets of Mogadishu in the worst bout of political violence in years.
Farmajo turns to Roble to help defuse the situation by asking him to organise elections.
But relations between the two men dramatically deteriorate as they trade accusations of abuse of power, exposing fresh divisions in the administration.
In the latest twist, Roble sacked the security minister Wednesday and replaced him with a Farmajo critic, prompting the president to call the decision unconstitutional.
The next phase of the elections is set to kick off for the lower house of parliament between October 1 and November 25.