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. Emmerson Mnangagwa, the former vice president sacked by Mugabe earlier this month, 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.

“When the process started, he then realised he had lost the party,” the source said.

Mugabe will receive a retirement package that includes a pension, housing, holiday and transport allowance, health insurance, limited air travel and security.

The ageing former president was “rugged and drained” by events of the past week and may travel to Singapore for medical checks in the coming weeks, the source said. He had been due to leave for Singapore in mid-November before the military put him under house arrest.

Mugabe has maintained that he leads a frugal life and that he does not possess any wealth or properties outside Zimbabwe.

But last month a legal quarrel between Grace and a Belgian-based businessman over a $1.3 million diamond ring lifted a veil on the wealthy lifestyle of Mugabe and his wife, nicknamed “Gucci Grace” for her reputed dedication to shopping.

In Zimbabwe, Mugabe runs a dairy business and the family has several farms while local and foreign media have reported that Grace has bought properties and luxury cars in South Africa.