HARARE (Reuters) - Robert Mugabe resigned as Zimbabwe’s president on Tuesday, a week after the army and his former political allies moved to end four decades of rule by a man once feted as an independence hero who became feared as a despot.

His former vice president, Emmerson Mnangagwa, whose sacking this month prompted the military takeover that forced Mugabe out, will be sworn in as president on Wednesday or Thursday, Patrick Chinamasa, legal secretary of the ruling ZANU-PF party, told Reuters.

The 93-year-old Mugabe had clung on for a week after an army takeover, with ZANU-PF urging him to go. He finally resigned moments after parliament began an impeachment process seen as the only legal way to force him out.

Wild celebrations broke out at a joint sitting of parliament when Speaker Jacob Mudenda read out Mugabe’s brief resignation letter. Mugabe, confined to his Harare residence, did not appear.

People danced in the streets of Harare and car horns blared at the news that the era of Mugabe -- who had led Zimbabwe since independence in 1980 -- was finally over. Some brandished posters of Mnangagwa and army chief General Constantino Chiwenga.

Workers turned the Christmas lights on early in Africa Unity Square and people climbed aboard armored vehicles to pose for photographs with soldiers.

Despite the public outpouring of joy, Mugabe’s downfall was as much the result of in-fighting among the political elite as a popular uprising, although thousands of people rallied against him in the days after the army intervened last week.

The army seized power after Mugabe sacked Mnangagwa, ZANU-PF’s favorite to succeed him, in a bid to smooth a path to the presidency for his wife Grace, 52, known to her critics as “Gucci Grace” for her reputed fondness for luxury shopping.

Since the crisis began, Mugabe has been mainly confined to his “Blue Roof” mansion in the capital where Grace is also believed to be.

ZANU-PF chief whip Lovemore Matuke told Reuters that Mnangagwa would be sworn in within 48 hours and serve the remainder of Mugabe’s term until the next election, which must be held by September 2018.

“DIGNITY AND JUSTICE”

“I am very happy with what has happened,” said Maria Sabawu, a supporter of the opposition Movement for Democratic Change (MDC), outside the hotel where the impeachment process was happening.

“I have suffered a lot at the hands of Mugabe’s government,” she said, showing her hand with a missing finger that she said was lost in violence during a presidential run-off election between Mugabe and opposition leader Morgan Tsvangirai in 2008.

Mugabe had led Zimbabwe since a guerrilla struggle ended white-minority rule in the country formerly known as Rhodesia.

He took the once-rich nation to economic ruin, presiding over the forced takeover of white-owned farms at the end of the century, which devastated agricultural foreign exchange earnings and led to hyperinflation.

But brandishing his anti-colonial credentials and styling himself the Grand Old Man of African politics, Mugabe retained the admiration of many people across the continent.

Amnesty International said that under Mugabe tens of thousands of people were tortured, forcibly disappeared or killed in a culture of impunity that allowed “grotesque crimes to thrive”.

Slideshow ( 15 images )

“The people of Zimbabwe deserve better. The next generation of leaders must commit itself to upholding the constitution, living up to Zimbabwe’s international human rights obligations and treating its people with dignity and justice,” the rights group said in a statement.

DECADES OF ISOLATION

Mnangagwa, 75, who fled Zimbabwe after his sacking in fear for his safety, was a chief lieutenant to Mugabe for decades and himself stands accused of participating in repression.

He was internal security chief in the mid-1980s when Mugabe deployed a North Korean-trained brigade against rebels during which 20,000 civilians were killed, according to rights groups.

Slideshow ( 15 images )

Reuters reported in September that Mnangagwa was plotting to succeed Mugabe, with army backing, at the helm of a broad coalition to seek Zimbabwe’s re-engagement with the world after decades of isolation from global lenders and donors.

Nicknamed “Ngwena”, or crocodile in the Shona language, an animal famed in Zimbabwean lore for its stealth and ruthlessness, Mnangagwa issued a statement from hiding on Tuesday calling on Zimbabweans to unite to rebuild the country.

Opposition politician and former education minister David Coltart said that call gave hope of lifting a shattered economy from its knees, provided Mnangagwa made good on his promise to reach out to other factions.

“When we all wake up with hangovers tomorrow, we will be reminded of the dreadful state our nation is in - no money in the banks and businesses collapsing,” Coltart told Reuters.

“As Emmerson Mnangagwa said, ZANU-PF is not capable of resolving this issue on its own. I took some comfort from his words. If he translates them into action, the future is positive.”

Zimbabwe’s Platform for Concerned Citizens, a civil society group, called for a national dialogue and a “transitional authority” to decide the country’s future.

Theresa May, prime minister of former colonial power Britain, said Mugabe’s resignation “provides Zimbabwe with an opportunity to forge a new path free of the oppression that characterized his rule”. She said Britain, as “Zimbabwe’s oldest friend”, would do all it could to support the country.

The U.S. embassy in Harare said 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.