Sudan's military leaders have reached an agreement with the opposition alliance to share power until elections can be held, mediators say.
The two sides agreed to rotate control of the sovereign council - the top tier of power - for at least three years.
They have also pledged to form an independent technocratic government and to investigate the violence of recent weeks, the African Union (AU) said.
News of the agreement reportedly sparked frenzied street celebrations.
Sudan has been in turmoil since the military ousted President Omar al-Bashir in April.
That followed a popular uprising against Mr Bashir, who seized power in a coup in June 1989.
Just days before the three-year transitional deal was announced, vast crowds took to the streets to demand that the ruling military council hand power to a civilian-led administration.
Seven people were killed and 181 were hurt in clashes that followed, state media reported.
The latest round of talks took place in the capital, Khartoum, earlier this week and were heavily mediated by the Ethiopian prime minister and members of the pan-African AU.
"The two sides agreed on establishing a sovereign council with a rotating military and civilian [presidency] for a period of three years or a little more," AU mediator Mohamed Hassan Lebatt told reporters early on Friday.
The agreement will see the military in charge for the first 18 months, then a civilian-run administration for the remaining 18 months.
It's "the first step in building a democratic country," said veteran politician Siddig Yousif, who was one of the main civilian negotiators.
Asked whether the civilian leaders could convince protesters who might be nervous about the presence of the military in government, Mr Yousif told the BBC: "It is a difficult task, but we'll try to convince our people that it will be a success".
Elections will be held once this transition period ends.
Both sides also "agreed to have a detailed, transparent, national, independent investigation into all the regrettable violent incidents that the country faced in recent weeks," he added.
They have also agreed to postpone the establishment of a legislative council.
"We hope that this is the beginning of a new era," Omar al-Degair, a leader of the opposition Forces for Freedom and Change (FFC), said after the announcement.
The deputy head of the Transitional Military Council (TMC), Gen Mohamed Hamdan Dagalo, said: "This agreement will be comprehensive and will not exclude anyone.
"We thank the African and Ethiopian mediators for their efforts and patience."
Protesters "definitely wanted much more" from the deal and many are a "little bit" sceptical about the details, says Lena al-Sheikh who was out on the streets of Khartoum at the height of the protests.
"We were saying: 'Congratulations, is this real?'" she told the BBC's Newsday programme.
"Because until 30 June, the military council has shown that... there was brutality against protesters, people died, people were hurt and we were thinking maybe this is never going to happen, maybe we are never going to reach an agreement."
People have reacted to news of the deal with a range of emotions
A sticking point for some people is that the military will choose the leader of the sovereign council first.
Yet Sudan-based journalist Yousra Elbagir reports that an ongoing internet blackout in the country means many people do not yet know this and other details of the deal:
Last month, representatives of the protesters were in talks with the military over who would take control of Sudan.
But negotiations collapsed when a military crackdown on 3 June left dozens of protesters dead. Doctors said 40 bodies were pulled from the River Nile the following day.
The army said it had scrapped all agreements with the opposition, and that elections would be held within nine months. But the protest movement insisted a transition period of at least three years was needed to ensure any elections are free and fair.
When talks broke down, Ethiopian Prime Minister Abiy Ahmed flew to Sudan to try to broker a new agreement between the two sides.
After days of talks, his special envoy, Mahmoud Dirir, then announced that protest leaders had agreed to suspend widespread strikes and return to the negotiating table.