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.
President Mohamed elevated deputy prime minister Mahdi Mohamed Guled to prime minister in an acting capacity, a statement issued by his office said, citing the need for continuity of government programmes.
The president's allies have also accused Khaire of failing to stabilise the security situation.
"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.
The president pledged to hold "a satisfactory election" within the schedule, but the Forum of National Parties, a leading opposition grouping, was sceptical.
"The president is breeding political chaos that will be difficult to manage... We warn against any attempt aimed at term extension," the group said.
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.