Sudan's ruling military council and main opposition coalition have signed a constitutional declaration which will pave the way for the formation of a transitional government.
Opposition leader Ahmed Rabie and Gen Mohamed Hamdan Daglo signed the deal.
A governing body of six civilians and five generals will oversee a three-year transition period.
Sudan has been in turmoil since the military ousted President Omar al-Bashir in April.
A formal signing ceremony of the document will be held on 17 August with the prime minister and other key officials announced soon after.
Mediators from the African Union and Ethiopia witnessed Sunday's signing of the constitutional declaration.
"We turned a tough page of Sudan's history by signing this agreement," Gen Dagolo, popularly known as Hemeti, told reporters.
Both sides signed a power-sharing accord in July, but demonstrators have been waiting since then for more details.
Protests first broke out in December after Mr Bashir's government imposed emergency austerity measures.
He was then overthrown by the military in April after prolonged protests outside the defence ministry in Khartoum.
What does the declaration say?
The document outlines the terms of a three-year transitional period agreed last month by the military council and opposition leaders.
The power-sharing deal envisages a governing body also known as the sovereign council of six civilians and five generals.
The council will then appoint a prime minister and a civilian transitional government.
A draft of the declaration seen by Reuters news agency said the paramilitary Rapid Support Forces (RSF), which have been accused of killing protesters, will now fall under the general command of the armed forces, and the intelligence service will be co-supervised by the sovereign council and the cabinet.
The deal on the declaration came after the military council announced that nine RSF soldiers had been dismissed and detained in connection with the killing of protesters, including four schoolchildren, this week.
The deaths had prompted mass demonstrations across the country and caused delays in the talks.
What has the reaction been?
People in the room clapped and cheered as the civilian and military representatives held up signed copies of the constitutional declaration.
Ethiopian mediator Mahmoud Drir hailed the deal saying it would "end Sudan's listing as a [state] sponsor of terrorism".
On the streets of the capital, hundreds danced and sang revolutionary songs and waved the national flag.
"Today, the civilian state is achieved," 21-year-old Nusseibeh Abdullah told Reuters news agency.
"Now we can tell the martyrs that their blood was not wasted," another protester called Omar Hussein told Reuters.
Egypt, Saudi Arabia and UAE, the main backers of the ruling military council, also welcomed the deal.
What do we know about the transition period?
The military and protesters have reached several agreements, with each side fleshing out new details as they try to overcome suspicion and build a working relationship.
They have so far agreed on the following:
- Power-sharing will last for 39 months
- A sovereign council, cabinet and legislative body will be formed
- A general will head the council for the first 21 months, a civilian for the remaining 18
- A prime minister, nominated by the pro-democracy movement, will head the cabinet
- The ministers of defence and interior will be chosen by the military.
The long transition period is seen as a victory for the pro-democracy movement - the generals had threatened a snap election after the 3 June crackdown.
Demonstrators argue that Mr Bashir's regime is so deeply entrenched that it will take time to dismantle its political network and open the way for free and fair elections.