Zimbabwe's president Robert Mugabe has resigned, the parliament speaker has said.
The surprise announcement came as an impeachment motion against Mugabe was debated in a joint sitting of parliament.
Mass spontaneous street parties broke out on the streets of Harare moments after the news broke.
A letter from Mr Mugabe said the decision was voluntary, Reuters news agency reports.
Mugabe, 93, had been expected to resign as a result of last week's military takeover and days of protests against his rule. During a televised address on Sunday he refused to stand down.
He has been in power since independence in 1980.
Mr Mugabe was sacked from his position as party's leader on Sunday.
The former vice-president Emmerson Mnangagwa, who Mugabe had fired, has been appointed as the new party leader.
The Zimbabwe ruling party official has said that Mr Mnangagwa will take over as the country's leader within 48 hours.
World leaders and diplomats have begun commenting on the events.
The UN secretary-general Antonio Guterres urged Zimbabweans "maintain calm and restraint" after Mugabe's resignation.
"The secretary-general and his predecessors have made clear that we expect all leaders to listen to their people," said Farhan Haq, Guterres' spokesman.
"That is a cornerstone of every form of government and needs to be followed in every continent and in every nation."
Theresa May, Prime Minister of Britain, from which Zimbabwe gained independence in 1980, said: "The resignation of Robert Mugabe provides Zimbabwe with an opportunity to forge a new path free of the oppression that characterised his rule. In recent days we have seen the desire of the Zimbabwean people for free and fair elections and the opportunity to rebuild the country’s economy under a legitimate government.
"As Zimbabwe’s oldest friend we will do all we can to support this, working with our international and regional partners to help the country achieve the brighter future it so deserves".
British Foreign Secretary Boris Johnson tweeted: "I will not pretend to regret Mugabe’s downfall." In a separate statement from the foreign office, he added: "This can now be a turning point, a moment of hope for this beautiful country, full of potential."
The United States said that Mugabe's resignation offered the country's people a "historic opportunity" for change and could help end its "isolation" on the world stage.
"The future of Zimbabwe will have to be decided by the people of Zimbabwe," said State Department spokeswoman Heather Nauert, issuing a call for "free and fair elections."
The US embassy in Harare also said that Zimbabwe was living "a historic moment".
"Whatever short-term arrangements the government may establish, the path forward must lead to free, fair and inclusive elections," it said in a statement.
Why did the world tolerate Mugabe for so long?
Mugabe has gone, but China will remain the key player in Zimbabwe
A profile of the disastrous rule of Robert Mugabe