Just hours after Madagascar's president handed over power to military leaders on Tuesday, they ceded control to his political rival.
In a radio broadcast from the capital, Antananarivo, vice-admiral Hyppolite Rarison Ramaroson placed opposition leader Andry Rajoelina in charge of the country.
Ramaroson said he and two other top generals rejected a move by the president to transfer his power to a military directorate.
African Union weighs in
Even before the military's decision, the Africa Union said it was opposed to Rajoelina being in charge.
Any assumption of power by non-constitutional means would be considered a coup d'etat, the union's senior diplomat, Jean Ping, told Reuters on Tuesday.
Earlier on Tuesday, also in a radio address, President Marc Ravalomanana told his country he had decided to step down "after deep reflection."
His term was up in 2011.
Elections promised within two years
An aide to Ravalomanana had said a military directorate composed of veteran, high-ranking military leaders, not yet named, would organize a national conference responsible for holding elections within two years.
Rajoelina has led anti-government protests in his bid for power, embroiling the tiny Indian Ocean island in weeks of unrest.
Over the weekend, Rajoelina had declared himself president of a transitional government and promised new elections within two years.
Army refused to arrest president
On Monday, he called on the army to arrest the president, but soldiers refused.
Tensions have been rising since late January, when the government blocked an opposition radio station's signal.
Rajoelina supporters set fire to a building in the government broadcasting complex as well as an oil depot, a shopping mall and a private TV station linked to Ravalomanana, killing scores of people.
Days later, soldiers opened fire on anti-government protesters, killing at least 25.
The incident cost Ravalomanana much of the support of the military, which blamed him for the order to fire at demonstrators.
The president, who remained hunkered in his official residence Tuesday surrounded by supporters and army guards.
A breakaway army faction had claimed it was neutral and interested only in restoring order, but the split in the military had greatly weakened the president.
Leadership in Madagascar is unclear as Madagascan President Marc Ravalomanana announced his resignation in favor of a military committee headed by Vice Admiral Hyppolite Ramaroson, only to have that resignation rejected by the Admiral, the military and opposition political groups. Admiral Ramaroson joined other military leaders in saying they would back opposition leader, former Antananarivo mayor and former DJ Andry Rajoelina.

Mr Ravalomanana attempted to hand power over to the heads of the military, given the tasks of discussing and drafting constitutional changes, rather than transfer power to Mr Rajoelina. After the resignation was announced to the opposition, four Army generals and a head of the church were detained for reasons unknown. The true extent of the Army's loyalty to Mr Rajoelina is unclear, as reportedly the military refused to arrest President Ravalomanana despite orders from Mr Rajoelina.

Mr Rajoelina installed himself in the Presidential Palace in upper Antananarivo, which troops had seized yesterday. A cabinet loyal to him has been in operation since the end of January, when Mr Rajoelina proclaimed Mr Ravalomanana's rule to be illegitimate. The Madagascan opposition accuses Mr Ravalomanana of mismanaging the country while restricting personal freedoms.

President Ravalomanana was reportedly first announced via an text message from one of his aides before being confirmed by Ravalomanana's office in a radio broadcast, in which the President proclaimed, "After deep reflection, I have decided to dissolve the government and give up power so that a military directorate can be established". Madagascan Army Chief of Staff Colonel Andre Ndriarijaona has declared his support for Rajoelina and says that "99% of the forces are behind" the opposition leader.
Eco-tourists visit Madagascar to see its unique wildlife. 
The African Union, meanwhile, reiterated its position that a military takeover in Madagascar would be considered a coup d'etat, which could result in "firm measures" such as Madagascar's suspension from the organization or a blocking of international aid, and urged the military to obey the country's constitution, which bars Mr Rajoelina from the presidency due to his age, and not hand power over to the former mayor, instead suggesting that power could be given to Madagascan Prime Minister General Charles Rabemananjara. Members of the Madagascan opposition say they plan to re-write the constitution and electoral code before holding new elections within two years.

While reports are that the country has been overall stable during the coup, the unrest of the past two months has deprived the country of tourist revenue. Tourism, especially eco-tourism highlighting the country's rainforests and unique mammal species, brings $800 million annually to the Madagascan economy.