Andry Rajoelina had proclaimed himself in charge of national affairs
The Madagascar capital's Mayor Andry Rajoelina has vowed to contest his sacking by the government, amid ongoing political turmoil in Antananarivo.
Madagascar's constitutional court also rejected Mr Rajoelina's petition to impeach President Marc Ravalomanana.
The 34-year-old called at the weekend for the president to quit and declared himself in charge of the country.
Dozens of people have died in protests in the last week amid the bitter power struggle between the two men.
Mr Rajoelina said he planned a rally of his supporters on Wednesday before city hall to protest the sacking.
"Antananarivo will not accept this decision. There is no valid reason to sack me. I don't fear being arrested," he was quoted as saying by AFP news agency.
On Tuesday, the constitutional court said impeachment powers rested not with judges but with members of parliament, which is controlled by the president's party.
Mr Rajoelina's replacement as mayor was named as Guy Randrianarisoa, a local city official.
Senior interior ministry official, Edmond Rakotomavo, told AFP news agency: "There was a decree issued by the interior ministry replacing the capital's leadership with a special delegation.
"We wanted to notify the mayor but he was not there."
After the president temporarily shut down the mayor's TV station last week, tens of thousands of people took to the streets, leading to deadly riots and looting.
President Marc Ravalomanana insists he is still in charge
Mr Rajoelina accuses the president - a 59-year-old self-made millionaire who won re-election in 2006 - of misspending public money and being a dictator.
The African Union has condemned any moves to overthrow the president and warned the rivals not to resort to unconstitutional methods to settle their dispute.
On Monday, at least six opposition leaders were arrested as they tried to organise a rally in the east of the Indian Ocean island nation.
Analysts say Mr Rajoelina has successfully tapped into widespread frustration with the government, but may have over-played his hand in trying to overthrow the president.
The large and beautiful island off the south-eastern coast of Africa has lurched from one crisis to another, putting off investors interested in exploiting its rich mineral reserves, its spices and its potential for tourism, correspondents say.