Somalia’s President Mohamed Abdullahi Farmajo has suspended the prime minister, who is facing allegations of involvement in the theft of land.
Mohamed Hussein Roble’s office said the president’s statement was outrageous and that he would continue as prime minister.
His allies said the president had attempted to stage an “indirect coup”.
Security forces tried but failed to block Mr Roble from entering his office on Monday, they added.
The two men have been involved in a long-running power struggle, raising fears that it could worsen instability in Somalia.
The US embassy in Somalia urged the leaders “to refrain from provocative actions, and avoid violence”.
Somalia has not had an effective central government since the overthrow of long-serving ruler Siad Barre in 1991.
The country is marred by disputes between rival politicians and clans. It is also battling an insurgency by al-Shabab, an al-Qaeda affiliate.
Mr Farmajo’s term officially ended in February but was extended because of disagreements over how to choose a new president.
A complex election for parliament, which involves clan elders choosing MPs, has been under way since November. It was supposed to have concluded by 24 December but the deadline was missed.
The two leaders have accused each other of undermining the elections.
Mr Farmajo said he was suspending the prime minister pending the outcome of an investigation into the corruption allegations.
Mr Roble was recently accused of being involved, along with other officials, in the misappropriation and theft of military-owned land in the capital, Mogadishu. He denied the allegation.
In a tweet after Mr Farmajo’s statement, the prime minister’s office said he was carrying on with his day-to-day duties “as usual”, and he remained committed to an “acceptable electoral process that culminates in a peaceful transfer of power”.
Assistant Information Minister Adala said the deployment of security forces around Mr Roble’s office would not stop him performing his duties.
“What is going on this morning is [an] indirect coup but it will not win,” he said.
The two leaders first clashed in April when Mr Farmajo extended his term in office, resulting in a stand-off between troops loyal to the two men in Mogadishu.
The pair clashed again in September when Mr Farmajo stripped Mr Roble of his power to hire and fire officials, but later reinstated them.