Zimbabwe's President Robert Mugabe has submitted his resignation after nearly four decades as the country's leader.

Mugabe defied demands to step down for almost a week after a military takeover and expulsion from his own ruling ZANU-PF party but stepped down on Tuesday, just as parliament started proceedings to impeach him.

Cheers broke out at a special session of parliament as speaker Jacob Mudenda read out Mugabe's resignation letter.

"I Robert Gabriel Mugabe in terms of section 96 of the constitution of Zimbabwe hereby formally tender my resignation ... with immediate effect," said Mudenda, reading the letter.

The news also sparked scenes of jubilation in the capital, Harare, as large crowds cheered, danced and sang, celebrating Mugabe's departure for hours.

"People are coming out onto the streets, they are calling this day Independence Day," Al Jazeera's Haru Mutasa, reporting from Harare, said.

{articleGUID}

"It's getting chaotic," she added. "Some people still can't believe this has happened. People say they are really excited and hoping for a better future."

At Harare's Rainbow Towers Hotel, crowds cheered as a picture of Mugabe - hung in most public business premises - was taken down.

Celebrations also erupted in central Johannesburg, in neighbouring South Africa, as Zimbabweans there also took to the streets to cheer on the news.

Mugabe's resignation brought an end to the impeachment process initiated by ZANU-PF after its Central Committee voted to dismiss him as party leader.

New era

Mugabe, 93, led Zimbabwe's fight for independence in the 1970s.

He came to power in 1980, and his 37-year rule was criticised for repression of dissent, election rigging, and for causing the country's economic collapse.

"Ever since I was born, I have never thought that I would see this day," Anthony Mutambirwa, a Harare resident, told Al Jazeera as news of Mugabe's resignation spread.

"I'm so glad. For 37 years, we have been suffering."

Mugabe's departure capped a historic week which saw the military seizing power, intervening in party politics over his succession.

Even though Mugabe's resignation letter did not specify who will succeed him, the most likely successor is ousted Vice President Emmerson Mnangagwa, whose sacking on November 6 triggered the turmoil.

{articleGUID}

Before their falling out, Mnangagwa, who has close ties with the army, had for decades been a faithful Mugabe lieutenant.

Nicknamed "The Crocodile", he was often described as the president's enforcer, and few would describe him as a democrat.

Mnangagwa is expected to become, within the next 48 hours, Zimbabwe's interim leader ahead of elections scheduled for next year.

"We expect Mnangagwa to play the game fairly," Paddington Japajapa, an opposition party member, told Al Jazeera in Harare.

"If he is not going to play the game fairly, we will take him on also. We are sick and tired of ZANU-PF's rule."

Mudenda, the speaker, said parliament would now ensure the "proper legal processes are put in place so that the country can proceed forward" and elect a new president.

'Overjoyed'

In a surprise move, Zimbabwe's military seized power on November 15, saying it wanted to "target criminals" around the 93-year-old who were leading the ruling ZANU-PF party and state astray.

Both the army and the influential war veterans' association were afraid Mugabe might hand power to his wife, Grace, seen as Mnangagwa's main opponent in ZANU-PF's succession battle.

In a rare sign of solidarity between the people and the army, which has often been a pillar of support for Mugabe's rule, tens of thousands of Zimbabweans took to the streets on Saturday to express support for the military's operation.

"Over the years, the army has been accused of being complicit with Mugabe," said Al Jazeera's Mutasa.

"People wanted Mugabe to go, so the only way to do this was to work with the military."

Victor Chifodya, a former Harare councillor, said he was "overjoyed at the news" of Mugabe's resignation.

"Mugabe was a very divisive man, but now people from all political parties have come together to make him resign," he told Al Jazeera.

"Now we can start a new Zimbabwe," added Chifodya.

However, some expressed concern about what a Mnangagwa presidency may bring.

"People don't know this, but he worked together with Mugabe for 57 years," Garikai Charambarara, a Harare resident, told Al Jazeera.

"Probably people are thinking he is one of the better devils, but, again, let's take it from there."

With reporting from Tendai Marima in Harare. Follow her on Twitter: @i_amten