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 just over 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 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 mediated by the Ethiopian prime minister and members of the pan-African AU.
What has been agreed?
"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 on Friday.
The agreement will see the military in charge for the first 21 months, then a civilian-run administration for the following 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."
What has the reaction been?
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."
BBC regional analyst Mohanad Hashim says the deal falls short of demands for a totally civilian administration.
A sticking point for some people is that the military will choose the leader of the sovereign council first.
"The first 18 months looks like the military meaning to consolidate power and remain in power and just bide [their] time until they are able to leverage that to remain in control," says Sudanese political commentator, Kholood Khair.
"What of [former President] Bashir? What of Salih Ghosh, the former head of the national intelligence service? There are many gaps in this document," Ms Khair told BBC Focus on Africa.
As Sudan-based journalist Yousra Elbagir reports, an ongoing internet blackout in the country means many people may not yet know the details of the deal:
Keep in mind that many of those out on the streets are only aware of what was announced in the presser (thanks to internet blackout) and not the composition of the presidential council or that TMC will choose their "President" first. https://t.co/EtW26Wk32b— Yousra Elbagir (@YousraElbagir) July 5, 2019
What is the background?
Last month, representatives of the protesters were in talks with the military over who would take control.
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 army said elections would be held within nine months. But the protest movement insisted on a transition period of at least three years.
When the talks broke down, Ethiopian Prime Minister Abiy Ahmed flew to Sudan to try to broker a new agreement.
After days of talks, his special envoy Mahmoud Dirir announced that protest leaders had agreed to suspend widespread strikes and return to the negotiating table.
Celebrations and scepticism have greeted the new deal. Will it hold? Fears of the unknown are not surprising.
In recent weeks the military appeared less willing to share power. But with international pressure and African Union mediation, they've accepted it.
The inclusion of a vague 11th member of the sovereign council, who AU mediators say "may or may not be a retired military officer" but is labelled civilian, may have convinced each side of a win.
But the position has the potential to make or break the deal. There are also concerns about the ambition displayed by Lt-Gen Mohamed Hamdan "Hemeti" Dagolo. The military council's number-two heads the dreaded Rapid Support Forces, a paramilitary group that's been accused of brutality.
Hemeti came into the limelight as a fierce commander of the government-backed Janjaweed militia in Darfur.
Lately, he has openly reached out to tribal elders and foreign leaders, and signed up a Canadian firm to spruce up the image of the military.
Many would be uncomfortable if Hemeti gets a prominent role in the new arrangement, which is likely.
Regional interests, particularly in the Gulf, have been at play before, during and after the coup.
Whether the changes are down to the activism and sacrifices made by ordinary Sudanese, or steered by a hidden foreign hand, the road ahead will be tough.