Zimbabwe’s former president Robert Mugabe was granted immunity from prosecution and assured that his safety would be protected in his home country as part of a deal that led to his resignation, sources close to the negotiations said on Thursday.

Mugabe, who had led Zimbabwe from independence in 1980, stepped down on Tuesday after the army seized power and the ruling party turned against him.

The former vice president Emmerson Mnangagwa, sacked by Mugabe earlier in November, is set to be sworn in as president on Friday.

A government source said Mugabe, who is 93, told negotiators he wanted to die in Zimbabwe and had no plans to live in exile.

“It was very emotional for him and he was forceful about it,” said the source, who is not authorised to speak on the details of the negotiated settlement.

“For him it was very important that he be guaranteed security to stay in the country, although that will not stop him from travelling abroad when he wants to or has to,” the source said.

Mugabe resigned on Tuesday as Parliament began a process to impeach him, sparking wild celebrations in the streets.

His rapid downfall after 37 years in power was triggered by a battle to succeed him that pitted Mnangagwa against Mugabe’s much younger wife, Grace.

“The outgoing president is obviously aware of the public hostility to his wife, the anger in some circles about the manner in which she conducted herself and approached Zanu-PF party politics,” a second source said.

“In that regard, it became necessary to also assure him that his whole family, including the wife, would be safe and secure.”

Mugabe had clung on to power for a week after the military intervened. He angered many Zimbabweans when he did not resign in a televised address on Sunday as many had anticipated.

The government source said the tipping point for him was the realisation that he would be impeached and ousted in an undignified way.

Related video click below: