Sudan’s ousted Prime Minister Abdalla Hamdok is to be reinstated, after being placed under house arrest during a military coup last month.
All political detainees will be released as part of a new agreement between the military, civilian leaders and ex-rebel groups, mediators said.
On 25 October, Sudan’s military had declared a state of emergency and dissolved the civilian leadership.
It sparked weeks of mass protests in which at least 40 people have died.
The deal was reached late on Saturday night, and is to be signed into action on Sunday, the head of Sudan’s Umma Party, Fadlallah Burma Nasir, confirmed.
Mr Hamdok has agreed to the terms so that further bloodshed can be avoided, Reuters news agency reports, citing a source close to him.
His office said restrictions on his movement had been lifted and that the security forces outside his house had left, AFP reports.
The group of mediators, which included academics, journalists and politicians, released a statement outlining the terms of the agreement, which said the rules governing the transition towards democracy would be restored.
Sudan’s military and the Forces for Freedom and Change (FFC), a loose coalition of civilian groups, have been in a fractious power-sharing arrangement since August 2019, after long-time leader Omar al-Bashir was overthrown amid mass protests.
That arrangement was thrown into crisis last month when military leader, Gen Abdel Fattah al-Burhan, dissolved the civilian arm of the government and arrested its leaders.
He had been due to step down as chairman of the governing council this month, when a civilian chosen by the FFC would become the head of state.
Gen Burhan, who appointed himself head of a new ruling council, insists the army’s action was not a coup.
He said he acted to prevent a civil war that was threatening to erupt because political groups had been inciting civilians against the security forces.
Across many cities, including the capital, Khartoum, anti-coup protesters put up makeshift barricades and burned piles of tyres, angry that their already-fragile path to democracy had been hijacked. The army responded violently, and are accused of shooting protesters.
One faction of the FFC has rejected the new deal, with demonstrations on Sunday going ahead as planned.
The international community condemned the coup and demanded the release of political prisoners. The World Bank froze its aid to Sudan, and the African Union (AU) suspended the country’s membership of the bloc.