Marc Ravalomanana has resigned as Madagascar's president and handed over power to the military a day after soldiers stormed his offices in the capital.
Ravalomanana has signed a document confirming his resignation, according to a statement issued by his office.
The statement said full powers were to be given to a military authority headed by the most senior officer of all forces. But it was not immediately clear who would be running the country as the opposition, led by Andry Rajoelina, has already said it has put in place a transitional government and taken over major ministries.
Ravalomanana, who won power seven years ago, was holed up at the presidential palace, about eight miles outside the capital, when troops seized his offices. He initially vowed to fight to the end and discussed military support with the United Nations and African states. But he appears to have bowed to the inevitable after the seizure of his offices following a declaration by the army chief of staff, Colonel Andre Ndriarijaona, that his forces had thrown their support behind Rajoelina. The opposition leader moved in to the presidential offices today and several cabinet ministers resigned.
Ndiarijaona said the military was almost completely behind Rajoelina, who at the weekend declared he had taken power and ordered Ravalomanana's arrest following weeks of political confrontation that has left more than 100 people dead.
"We are there for the Malagasy people. If Andry Rajoelina can resolve the problem, we are behind him," said Ndriarijaona, who replaced the previous army chief of staff after last week's mutiny. "I would say 99% of the forces are behind him."
However, there are signs the army is divided and it is not clear if a power struggle is in the making between elements of the military hostile to Rajoelina and his new administration.
Ravalomanana may have set up a confrontation by giving power to a military board, to be led by Admiral Hyppolite Ramaroson, whose loyalties are not immediately clear.
The African Union commission chairman, Jean Ping, today called on the army not to hand over to the opposition, saying this would be "unconstitutional", but instead to retain power.
The ousted president earlier also described demands for him to relinquish power as unconstitutional and accused Rajoelina's movement of using "fear and repression to survive".
Rajoelina, a 34-year-old former disc jockey who moved against the government after he was sacked as the capital's mayor in February, announced the creation of a two-year interim government before new elections are held.
Ravalomanana had proposed a referendum on his rule after public outrage over a massacre of 28 civilian protesters when the army was ordered to open fire on an anti-government demonstration in February. But the opposition rejected the referendum and issued a warrant for Ravalomanana's arrest for allegedly violating the constitution, including hiring mercenaries to prop up his government.
"The people are thirsty for change and that's why we won't have a referendum and will put our transitional government in place," said Rajoelina.
Last week the US ambassador to Madagascar, Niels Marquardt, warned the country was on the verge of civil war after the former army chief, Edmond Rasolofomahandry, and the defence minister, Vice-Admiral Mamy Ranaivoniarivo, were forced from office by junior officers.
As Antananarivo's mayor, Rajoelina organised protests against rising food prices and government graft. He brought tens of thousands of people onto the streets, resulting in violent confrontations with government forces. At one point he sought shelter in the embassy of the former colonial power, France, prompting accusations that Paris was backing his attempt to topple the government.
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.