Zimbabwe's President Robert Mugabe has resigned after 37 years of autocratic rule, finally succumbing to the pressure of a military takeover and the humiliation of impeachment.

The announcement came minutes into a joint session of the Zimbabwean Parliament in Harare, convened to prise the 93-year-old from power.

As the Speaker read out a letter from Mugabe, lawmakers broke out in thunderous applause and cheers.

In the streets outside, crowds erupted in rapturous celebrations, dancing and cheering in joy, some raising their fists and waving Zimbabwean flags.

"We think that this is the work of God," one young man told CNN in Harare. "We were in crisis for a long time, and this is a new day for Zimbabweans."

In his letter, Mugabe insisted that his resignation was voluntary. "I have resigned to allow smooth transfer of power," he wrote. "Kindly give public notice of my decision as soon as possible."

Key developments

Mugabe's whereabouts: The President's resignation came in a short letter read out during a parliamentary session. He has not been seen since Sunday.

No sign of successor: It was not immediately clear who would take over. The former Vice President, whose sacking by Mugabe triggered the crisis, earlier said he would not return from abroad until his safety could be guaranteed.

International reaction: Theresa May, the Prime Minister of Britain, from which Zimbabwe gained independence in 1980, said Mugabe's resignation provided the country "with an opportunity to forge a new path free of the oppression that characterized his rule."

What happened

Mugabe's decision was an acknowledgment of the inevitable. In reality, he lost his grip on power six days ago when the country's top generals launched what amounted to a military coup, placing the veteran leader under house arrest.

After nearly four decades of unimpeded rule, Mugabe's political downfall unfolded in just two weeks.

The crisis began on November 6 when Mugabe fired his Vice President, Emmerson Mnangagwa, in an apparent attempt to clear a path for his wife, Grace, to succeed him.

The prospect of Grace Mugabe in power horrified the generals and other senior elements in Mugabe's ZANU-PF party, who despise the First Lady's lavish lifestyle and were suspicious of her political ambitions.

On Tuesday, tanks were seen outside Harare and in the early hours of Wednesday morning, an army spokesman appeared on state TV to declare that a military operation was under way. By dawn it was clear that Mugabe was under house arrest, and his grip on power was over.

The whereabouts of the former President and his wife were unknown on Tuesday. Grace Mugabe has not been seen since the day of the military takeover, and her husband's last appearance was during a television statement on Sunday night.

What comes next

It was not clear who would take over from Mugabe. Had Mnangagwa had not been fired as Vice President, he would have served as interim leader. In his absence, the Speaker of Parliament would ordinarily step in.

Mnangagwa has not been seen in the country since his dismissal on November 6, but he broke his silence on Tuesday to add his voice to those calling on Mugabe to resign. Mnangagwa, who enjoys widespread support in the military, was widely believed to be in touch with senior generals behind the scenes.

ZANU-PF ousted Mugabe as leader of the party and installed Mnangagwa in his place on Sunday, and at the very least, Mugabe's resignation paves the way for him to stand for the presidency in elections planned for 2018.

End of an era

Mugabe's resignation marks the end of an era in Zimbabwe. He ruled the country with an iron fist for almost four decades and is the only leader the nation has known since it achieved independence from Britain in 1980.

Mugabe's political demise is the consequence of a struggle over who would succeed him in ZANU-PF, a party split between those loyal to Mnangagwa and supporters of Grace Mugabe.

It was a humiliating departure for Mugabe, who clung onto power for a week but eventually buckled to pressure.

The party he co-founded to usher the country into independence ousted him, the military that he commanded placed him under house arrest and his most powerful allies abandoned him.

Mugabe rose to power as a freedom fighter and was once regarded as Zimbabwe's own Nelson Mandela, but he quickly waged a campaign of oppression to shore up his authority, extinguishing the political opposition through violent crackdowns.

Mugabe's hardline policies also pushed the country into poverty. Its flourishing economy began to disintegrate after a program of land seizures from white farmers, and agricultural output plummeted and inflation soared.

Over the decades, Mugabe and his wife faced fierce criticism for leading lavish lifestyles as the country was plunged into economic ruin.

CNN's Hilary Clarke contributed to this report.