Burkina Faso's President Blaise Compaore has announced his resignation following violent protests over his attempt to extend his 27-year rule.
Mr Compaore issued a statement saying the presidency was now vacant and urging elections within 90 days.
Army chief Gen Honore Traore said he had taken over, but it was not clear if he had the backing of all the military.
Crowds danced and cheered in the capital, Ouagadougou, after Mr Compaore's resignation was broadcast.
On Thursday, protesters angry at his attempt to amend the constitution set fire to parliament and government buildings.
There was a euphoric atmosphere in the Place de la Nation as the thousands of protesters heard that Blaise Compaore was no longer their president.
But the crowds have no intention of going home, as they are unhappy that Gen Honore Traore has been appointed as transitional head.
He is seen as too close to the ousted president - he was Blaise Compaore's aide de camp - and for these demonstrators that is not enough of a rupture with the past.
"This is not a coup - this is a popular uprising," one man in the crowd said.
How Blaise Compaore sparked his own downfall
Mr Compaore had earlier vowed to remain in power until a transitional government completed its work in 2015, although he had agreed not to seek another term.
However, the opposition continued to demand that he resign - a key leader, Zephirin Diabre, urged protesters to occupy public spaces.
After the resignation, Mr Diabre told the BBC's Focus on Africa radio programme that he was relieved by the resignation and called on opposition groups to "work on the transition to take care of our country".
It could be a year before elections are held, he said, "because you need to revive the constitution, maybe draw up a new constitution. That would take at least 12 months".
Mr Compaore's statement, which he read on television, said: "In order to preserve the democratic gains, as well as social peace, I declare a power vacuum to allow the establishment of a transition leading to free and fair elections within a maximum of 90 days."
He added: "For my part, I think I have fulfilled my duty."
His whereabouts now remain unclear.
However, media reports said a heavily armed convoy believed to be carrying Mr Compaore was travelling towards the southern town of Po, near the border with Ghana.
Jump media playerMedia player helpOut of media player. Press enter to return or tab to continue.
President Compaore had earlier urged talks with all parties
One protester, Sam, told the BBC: "Blaise Compaore has gone away, he's running away and we are happy. The words are not coming so easy because I'm very happy, my children are going to know another president."
Under Article 43 of the constitution, the president of the senate should take over after the president resigns, and elections should take place between 60 and 90 days afterwards.
However, the military announced a state of emergency and the dissolution of both houses of parliament on Thursday - effectively leaving a power vacuum.
In his statement, military chief Gen Traore said: "In line with constitutional measures, and given the power vacuum... I will assume as of today my responsibilities as head of state."
But army spokesman Lt Col Isaac Zida later told reporters the constitution had been suspended.
"The civilian and armed forces have decided to take the destiny of the nation in hand," he said.
The "length and makeup of the transitional body [responsible for organising elections] will be decided later," he added.
It was unclear whether Lt Col Zida was speaking on behalf of Gen Traore, or as a rival.
The BBC's Yacouba Ouedraogo, in Ouagadougou, says there may be a split in the army, with Lt Col Zida saying he will lead the transition, not Gen Traore.
BBC's James Copnall on Blaise Compaore's career
BBC News looks back at Blaise Compaore's three decades of power
Blaise Compaore was a young army officer when he seized power in 1987. A taciturn man, he became known as Beau Blaise - good-looking Blaise. The nickname did not necessarily suggest he was popular. Many blamed him for the death of his predecessor, the charismatic revolutionary Thomas Sankara, who was killed by soldiers in mysterious circumstances.
Controversy would be a perpetual feature of Beau Blaise's time in power. The president was accused of stoking rebellions around West Africa. Yet over time Mr Compaore oversaw a transformation of his image, internationally at least. This inflammatory figure became a man relied upon to put out fires around the region.
Mr Compaore won a series of elections, though the opposition always complained the odds were stacked dramatically in his favour. He largely followed the economic orthodoxy prescribed by international financial institutions. But Burkina Faso did not escape the poverty trap. It remains one of the least developed countries in the world.