Zimbabwe's former vice-president, whose sacking sparked events leading to the shock resignation of long-time leader Robert Mugabe, has returned to take charge of the country, state TV says.
Emmerson Mnangagwa, who fled to South Africa two weeks ago, will be made the new president on Friday (local time), it said.
His dismissal led the ruling party and the military to intervene and force an end to Mr Mugabe's 37-year long rule.
The news sparked wild celebrations across the country late into the night.
The announcement that the 93-year-old president was stepping down came in the form of a letter read out in parliament on Wednesday, abruptly halting impeachment proceedings against him.
In it, Mr Mugabe said he was resigning to allow a smooth and peaceful transfer of power, and that his decision was voluntary.
A spokesman for the ruling Zanu-PF party said Mr Mnangagwa, 71, would serve the remainder of Mr Mugabe's term until elections that are due to be held by September 2018.
The state-run Zimbabwe Broadcasting Corporation (ZBC) confirmed that his swearing-in ceremony had been scheduled for Friday.
Nicknamed the "crocodile" because of his political cunning, Mr Mnangagwa issued a statement from exile calling on Zimbabweans to unite to rebuild the country.
"Together, we will ensure a peaceful transition to the consolidation of our democracy, and bring in a fresh start for all Zimbabweans and foster peace and unity," Mr Mnangagwa told Zimbabwe's NewsDay on Tuesday.
He met South African President Jacob Zuma before leaving for Zimbabwe.
Mr Mnangagwa's firing by Mr Mugabe two weeks ago triggered an unprecedented political crisis in the country.
It had been seen by many as an attempt to clear the way for Grace Mugabe to succeed her husband as president and riled the military leadership, which stepped in and put Mr Mugabe under house arrest.
Under the constitution, the role of successor would normally go to a serving vice-president, and one still remains in post - Phelekezela Mphoko.
However, Mr Mphoko - a key ally of Grace Mugabe - has just been fired by Zanu-PF and is not believed to be in the country. In his absence, the party has nominated Mr Mnangagwa, the speaker of parliament confirmed.
Some have questioned whether the handover to Mr Mnangagwa will bring about real change in the country.
He was national security chief at a time when thousands of civilians died in post-independence conflict in the 1980s, though he denies having blood on his hands.
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".
Prominent opposition politician David Coltart tweeted: "We have removed a tyrant but not yet a tyranny."
African Union president Alpha Condé said he was "truly delighted" by the news, but expressed regret at the way Mr Mugabe's rule had ended.
"It is a shame that he is leaving through the back door and that he is forsaken by the parliament," he said.
Celebrations in the streets
At 93, Mr Mugabe was - until his resignation - the world's oldest leader. He once proclaimed that "only God" could remove him.
Lawmakers from the ruling party and opposition roared with glee when his resignation letter was read aloud in parliament on Wednesday.
Activist and political candidate Vimbaishe Musvaburi broke down in tears of joy while speaking to the BBC.
"We are tired of this man, we are so glad he's gone. We don't want him anymore and yes, today, it's victory," she said.
Robert Mugabe - Timeline of a political life
- 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
- BBC