Somalia's parliament ousted Prime Minister Hassan Ali Khaire in a no-confidence vote on Saturday, as a simmering power struggle between him and the president came to the fore.
Khaire, and President Mohamed Abdullahi Mohamed, have been tussling over whether to delay a national election due in February next year, with the prime minister insisting it go ahead and the president favouring postponement.
The president's allies have also accused Khaire of failing to stabilise the security situation.
Lawmakers voted 170-8 to remove Khaire from office.
"The government failed in its promise on the preparation of a clear plan for the one man, one vote election," said Mohamed Mursal Sheikh Abdirahman, the speaker of parliament, referring to the first direct election since civil war erupted in 1991.
The Horn-of-Africa country has been holding elections through representatives like elders in the past decade, due to insecurity caused by al Shabaab militants in most areas.
Mohamed Abukar Islow, the internal security minister and a key ally of Khaire, accused the speaker and the president of plotting to remove the prime minister to extend their terms.
"It is a dark day," Islow said, terming the move unconstitutional due to the requirement that an election be held every four years. Khaire, a former oil company executive, was not immediately available for a comment.
President Mohamed said in a statement carried on the state radio website that he had accepted the decision of lawmakers to remove Khaire, citing the need to preserve the unity of the various arms of government.
Rashid Abdi, an independent Horn of Africa analyst, said Khaire's removal was inevitable because of differences with the president and the prime minister's ambition to be president one day.
"What was surprising was the swiftness with which it was done. There was no debate or negotiations," Abdi told Reuters.