Somalia's lower house of parliament on Monday voted to extend the president's mandate for two years, after months of deadlock over the holding of elections in the fragile nation.
But the speaker of the Senate upper house, which has to approve the legislation, immediately slammed the move as unconstitutional.
The country has been in a constitutional crisis since the mandate of President Mohamed Abdullahi Mohamed, better known by his nickname Farmajo, ran out in February.
Farmajo and the leaders of Somalia's five semi-autonomous federal states had reached an agreement in September that paved the way for indirect parliamentary and presidential elections in late 2020 and early 2021.
But it fell apart as squabbles erupted over how to conduct the vote, and multiple rounds of talks have failed to break the impasse between Mogadishu and the states.
The bill adopted Monday paves the way for a one-person, one-vote election in 2023 -- the first such direct poll since 1969.
"One legislator abstained, three have refused and 149 lawmakers voted in favour of the bill so that it is valid," said speaker Mohamed Mursal.
Farmajo said the bill was introduced after member states "sabotaged" previous efforts to hold an election.
"The government will play its role in implementing this law... which guides the country to holding direct elections as it returns to the Somali people their constitutional rights," the president said in a statement.
The move was condemned by several upper house senators.
Speaker Abdi Hashi Abdullahi said it would "lead the country into political instability, risks of insecurity and other unpredictable situations."
Another senator, Ilyas Ali Hassan, said the move was "unconstitutional".
"Firstly the parliament's mandate has expired and they have no authority to introduce election law," he said.
"And even if they had a mandate, there is no way the lower house alone can introduce an election law without the endorsement of the upper house so the whole thing is nonsense."
Adding to the drama of the day, Mogadishu police chief Sadaq Omar Hassan was promptly fired after releasing a video message announcing he was suspending parliament.
"There should be political agreement over issues and there should not be stealing. We call on the legislators to go back to their constituencies and seek confidence for re-election," he said.
Somalia has not had an effective central government since the collapse of Siad Barre's military regime in 1991, which led to decades of civil war and lawlessness fuelled by clan conflicts.
The country also still battles the Al-Qaeda-linked Al-Shabaab Islamist militant group, which controlled the capital until 2011 when it was pushed out by African Union troops.
Al-Shabaab retains parts of the countryside and carries out attacks against government, military and civilian targets in Mogadishu and regional towns.
Somalia still operates under an interim constitution and its institutions, such as the army, remain rudimentary, backed up with international support.
In this article: