Madagascar's President Marc Ravalomanana has said he is standing down and handing power to the military.
But military leaders were reported to favour a direct transfer to 34-year-old opposition leader Andry Rajoelina.
Mr Rajoelina has installed himself in the president's offices, seized on Monday by pro-opposition troops.
A BBC correspondent in Madagascar says it seems clear Mr Ravalomanana is stepping down, but there is confusion over how it will be done.
It is unclear whether the generals chosen by Mr Ravalomanana to head a new military directorate are willing or able to take over, the BBC's Jonah Fisher says.
There were unconfirmed reports that those generals had been arrested.
The crisis on the Indian Ocean island has left 100 people dead since January.
The African Union and the Southern Africa Development Community (SADC) have condemned any direct seizure of power by Mr Rajoelina.
"We don't think anybody has the right to unseat an elected government by force," Botswanan Foreign Minister Phando Skelemani told the BBC, speaking on behalf of SADC.
UN Secretary General Ban Ki-moon expressed grave concern at the unrest in Madagascar, appealing to all parties to ensure a "smooth transition".
In a radio address announcing his resignation Mr Ravalomanana said he had decided to give up power after "deep reflection".
"This decision was very difficult and very hard, but it had to be made. We need calm and peace to develop our country," he said.
He added that power would be handed to a military directorate, but it is understood that the head general turned down an offer to take over.
A spokesman for Mr Ravalomanana told Reuters news agency power had been handed to the most senior figure in the military, navy admiral Hyppolite Ramaroson.
But Col Andre Ndriarijaona, who last week said he had replaced the military chief of staff, said the military preferred Mr Rajoelina.
Mr Ravalomanana's resignation marks a dramatic victory for Mr Rajoelina, who was sacked as mayor of the capital in February.
The former disc jockey took up office at the presidential residence in central Antananarivo on Tuesday before emerging triumphantly to parade among thousands of supporters.
He has announced there will be a new constitution and elections within 24 months
The current constitution sets a minimum age of 40 for presidential candidates. Mr Rajoelina is 34.
Earlier, a number of government ministers quit, as power ebbed away from the president.
Our correspondent says the mood on the streets was one of relief following fears of a bloody last stand if Mr Ravalomanana had continued to cling to power.
Mr Ravalomanana had said he was ready to fight to the death at the Iavoloha palace, about 15km (nine miles) from the city centre.
On Monday, Mr Rajoelina, who has declared himself president, rejected Mr Ravalomanana's offer of a referendum to solve the crisis and called for his arrest.
Later that day, troops stormed the presidential residence in the centre of the capital and also seized the central bank.
Mr Ravalomanana was re-elected for a second term in office in 2006 and under him, Madagascar's economy has opened up to foreign investment, particularly in mining.
But 70% of the 20 million population still lives on less than $1 (£0.7) a day and correspondents say the opposition has tapped into popular frustration at the failure of this new wealth to trickle down.
Mr Rajoelina had said the president has been a tyrant who misspent public money but Mr Ravalomanana's supporters said his rival is a young troublemaker who has not offered any policy alternatives
|Liveleak on Facebook|