Zimbabwe's President Robert Mugabe has resigned, bringing an end to 37 years of rule and sparking jubilant celebrations in the nation's streets.
A letter from Mr Mugabe read out by the speaker of parliament said the decision was voluntary and he had made it to allow a smooth transfer of power.
The news abruptly halted an impeachment hearing that had begun against him.
The ruling Zanu-PF party says former vice-president Emmerson Mnangagwa will succeed Mr Mugabe, in power since 1980.
Mr Mnangagwa's sacking earlier this month triggered a political crisis.
It had been seen by many as an attempt to clear the way for Grace Mugabe to succeed her husband as leader and riled the military leadership, who stepped in and put Mr Mugabe under house arrest.
After the resignation announcement, lawmakers roared in jubilation.
Mr Mugabe, 93, was until his resignation the world's oldest leader. He had previously refused to quit despite last week's military takeover and days of protests.
According to the constitution his successor should be the current vice-president, Phelekezela Mphoko, a supporter of Grace Mugabe.
But Zanu-PF chief whip Lovemore Matuke told Reuters news agency that Mr Mnangagwa would be in office "within 48 hours".
Speaking from an undisclosed location earlier on Tuesday, Mr Mnangagwa said he had fled abroad two weeks ago when he learned of a plot to kill him.
A city sings
Driving through Harare, the cheers and the blaring of car horns signalled the end of the Mugabe era.
The man who dominated Zimbabwe for so long has already begun to fade into history here. It is a city singing with the noise of joy.
Exactly a week after the military first moved against President Mugabe, I was standing in parliament as legislators debated the motion to impeach him.
Suddenly, there was cheering.
An usher approached the speaker and handed him a letter. He stood to speak and we strained to hear his words. They were muffled but momentous. Robert Mugabe had resigned.
On the floor of the parliament I met jubilant MPs. Some danced. Celebrations spilled into the hallways and out into the street.
A people who endured white minority rule and then saw their independence become tyranny found themselves suddenly free.
'Let him rest in his last days'
UK Prime Minister Theresa May said Mr Mugabe's resignation "provides Zimbabwe with an opportunity to forge a new path free of the oppression that characterised his rule".
She said that former colonial power Britain, "as Zimbabwe's oldest friend", will do all it can to support free and fair elections and the rebuilding of the Zimbabwean economy.
Opposition leader Morgan Tsvangirai told the BBC he hoped that Zimbabwe was on a "new trajectory" that would include free and fair elections. He said Mr Mugabe should be allowed to "go and rest for his last days".
In other reaction:
The US Embassy in Harare, the capital, said it was a "historic moment" and congratulated Zimbabweans who "raised their voices and stated peacefully and clearly that the time for change was overdue"
South Africa's main opposition Democratic Alliance welcomed the move, saying Mr Mugabe had turned from "liberator to dictator"
Prominent Zimbabwean opposition politician David Coltart tweeted: "We have removed a tyrant but not yet a tyranny"
Civil society group the Platform for Concerned Citizens called for dialogue between all political parties, which it said should lead to the formation of a national transitional authority
Robert Mugabe won elections during his 37 years in power, but over the past 15 years these were marred by violence against political opponents.
He presided over a deepening economic crisis in Zimbabwe, where people are on average 15% poorer now than they were in 1980.
However, Mr Mugabe was not forced out after decades in power by a popular mass movement but rather as a result of political splits within his Zanu-PF party.
The leader of the influential liberation war veterans - former allies of Mr Mugabe - said after the army takeover that Mr Mugabe was a "dictator", who "as he became old, surrendered his court to a gang of thieves around his wife".
Both he and Grace, 52, are believed to be at a mansion in Harare.
"We are just so happy that things are finally going to change," Togo Ndhlalambi, a hairdresser, told the AFP news agency.
"I am the happiest person under the sun right now, because I always believed that Mugabe was going to step down in my lifetime and it has happened," human rights activist Linda Masarira told the BBC.
"And now going forward it's time for the opposition to reorganise and ensure that we will have a government that cares for the people. And everyone has to be included."
1924: Born in Kutama
1964: Imprisoned by Rhodesian government
1980: Wins post-independence elections
1996: Marries Grace Marufu
2000: Loses referendum, pro-Mugabe militias invade white-owned farms and attack opposition supporters
2008: Comes second in first round of elections to Morgan Tsvangirai who pulls out of run-off amid nationwide attacks on his supporters
2009: Amid economic collapse, swears in Mr Tsvangirai as prime minister, who serves in uneasy government of national unity for four years
2017: Sacks long-time ally Vice-President Emmerson Mnangagwa, paving the way for his wife Grace to succeed him. Army intervenes and forces him to step down