Sudan's ruling generals and protest leaders signed a hard-won constitutional declaration on Sunday, paving the way for a transition to civilian rule after more than seven months of demonstrations and violence.
Under the agreement, signed at a ceremony in the capital Khartoum, a joint civilian-military ruling body will oversee the formation of a civilian government and parliament to govern for a three-year transition period.
The declaration was the result of fraught negotiations between the leaders of mass protests, which erupted last December against the three-decade rule of president Omar al-Bashir, and the generals who ousted him in April.
It builds on a July 17 power-sharing deal between the two sides.
Protest movement leader Ahmed Rabie and the deputy head of the ruling military council General Mohamed Hamdan Daglo signed the declaration at a ceremony attended by African Union and Ethiopian mediators.
"We turned a tough page of Sudan's history by signing this agreement," Daglo, who flashed a victory sign after making a short speech, told reporters.
The signing was met by applause in the hall as representatives from both sides shook hands.
Members of the protest umbrella group, the Alliance for Freedom and Change, broke into tears as they exchanged hugs.
Crowds of jubilant Sudanese gathered outside the hall, chanting "blood for blood, our government is civilian" and "revolution, revolution".
In the Bahari district of north Khartoum, dozens were chanting "this country is ours and the government is civilian" as drivers honked their horns in celebration.
In the city of Omdurman, hundreds were clapping, chanting and dancing to drum beats.
A formal signing with foreign dignitaries in attendance is to take place on August 17, another protest leader, Monzer Abu al-Maali, told AFP.
On the same day, Bashir is due to go on trial on corruption charges.
The next day, the generals and protest leaders are to announce the composition of the new transitional civilian-majority ruling council, Abu al-Maali said.
"The prime minister will be named on August 20 and cabinet members on August 28," he said, adding that the sovereign council and cabinet would meet for the first time on September 1.
'Martyrs' blood not wasted'
The talks had been repeatedly interrupted by deadly violence against demonstrators who have kept up rallies to press for civilian rule.
Talks were suspended for weeks after men in military uniform broke up a long-running protest camp outside army headquarters in Khartoum on June 3, killing at least 127 people, according to doctors close to the protest movement.
The movement has laid most of the blame on the powerful Rapid Support Forces (RSF) paramilitary group, commanded by Daglo.
Protest leaders say the accord calls for an investigation into protest-related violence which, according to protest-linked doctors, has cost more than 250 lives since December.
Under Sunday's deal, RSF paramilitaries are to be integrated into the army's chain of command.
Omar Hussein, a protester waving the Sudanese flag outside the negotiations hall, was overjoyed by the signing.
"Now we can tell the martyrs that their blood was not wasted," he said.
Ibtisam al-Sanhouri, a legal affairs negotiator for the protest movement, said the constitutional declaration clears the way for a parliamentary system with a civilian prime minister.
She said the protest movement would have 201 of 300 seats in parliament and the premier, to be confirmed by the new sovereign council.
The document touches on a peace deal agreed with three armed groups last month in Addis Ababa, protest leader Babiker Faisal said.
These groups had spent years fighting Bashir's government forces in the states of Darfur, Blue Nile and South Kordofan.
"A comprehensive peace conference is planned to take place within six months of the transitional period," he added.
Sudan's Arab neighbours hailed the long-awaited deal.
Egypt said it was "a significant step on the right track", while the Saudi foreign ministry welcomed it as "a quantum leap that will transition Sudan to stability and security".
In the United Arab Emirates, minister of state for foreign affairs Anwar Gargash said Sudan's transition to civilian rule "turns the page" on Bashir and his Islamist allies.
On Sunday, Ethiopian mediator Mahmoud Drir told reporters the deal would see Sudan removed from the United States' blacklist as a state sponsor of terrorism.
The country has been on the State Department's list since 1993 over its alleged support of Islamist militants, a designation that has damaged the country's economy and severely impeded foreign investment.