Sudan‘s ruling generals and protest leaders have signed a constitutional declaration that paves the way for a transition to civilian rule, a hard-fought agreement that came after a long period of negotiations following the overthrow of President Omar al-Bashir in the wake of mass protests.

General Mohamed Hamdan Dagalo, the deputy head of the Transitional Military Council (TMC), and Ahmed Rabie, a protest leader, signed the declaration on Sunday at a ceremony in the capital, Khartoum, that was attended by African Union and Ethiopian mediators.

The document builds on a power-sharing deal agreed to last month and provides for a joint civilian-military ruling body to oversee the formation of a transitional civilian government and parliament to govern for a period of a little more than three years until elections can be held.

The signing was met by a wave of applause in the Khartoum hall as representatives from both sides shook hands.

A formal signing in front of foreign dignitaries is due to take place on August 17 in Khartoum. The following day, the generals and protest leaders are expected to announce the composition of the new transitional civilian-majority ruling council.

A new prime minister, appointed by the main opposition coalition, the Forces of Freedom and Change (FFC), is expected to be named on August 20, The prime minister will be tasked to form the government in consultation with the FFC. However, the defence and the interior ministers will be appointed by the military council.

The cabinet, which will be named on August 28, and the ruling council will meet together on September 1, sources told Reuters news agency, ahead of the appointment of a legislative assembly in three months.

The deal on a constitutional declaration is the fruit of difficult negotiations between the leaders of mass protests which erupted last December against al-Bashir’s three-decade rule and the generals who eventually overthrew him in April.

The talks had been repeatedly interrupted by deadly violence in Khartoum and other cities against demonstrators who have kept up rallies to press for civilian rule.

Speaking from Doha, Al Jazeera’s Mohammed Adow said the agreement “means Sudan has embarked on the road to that much-desired democracy that people have been protesting for months, and also it is momentous for the African Union which has mediated between the parties in Sudan.

“This is a new thing that’s coming in the continent – a hybrid transitional authority that has both military officials and civilians working together during a period of transition – so there are bound to teething problems, but then again many people in Sudan are still hopeful that they have come this far.”

In late May, the TMC shut down Al Jazeera’s Khartoum bureau and banned its journalists from reporting from the country.