Sudan has been rocked by a political crisis since the army ousted longtime ruler Omar al-Bashir in April on the back of widespread protests, with the ruling generals resisting demonstrators' demands to hand power to a civilian administration.
On Friday, Sudan's ruling generals and protest leaders reached an agreement on the disputed issue of a new governing body, mediators said, in breakthrough talks aimed at ending the country's months-long political crisis.
"The two sides agreed on establishing a sovereign council with a rotating military and civilian (presidency) for a period of three years or little more," African Union mediator Mohamed El Hacen Lebatt told reporters.
The power-sharing agreement came after two days of talks that resumed on Wednesday after the previous round of negotiations collapsed in May over who should lead the ruling body - a civilian or soldier.
The tension between the ruling generals and protest leaders had further soared after a brutal raid on a longstanding protest camp in the capital Khartoum that killed dozens of demonstrators and wounded hundreds on 3 June.
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," including the 3 June raid, Mr Lebatt said.
The ruling generals had previously rejected calls for an independent investigation from protest group The Alliance for Freedom and Change and had launched their own enquiry.
The latest round of talks came through after intense mediation by Ethiopia and African Union between the two rival groups.

Members of the Sudanese Military Council and the protest movement the Alliance for Freedom and Change meet. Source: AFP
Darfur rebels released
The joint Ethiopian and African Union blueprint calls for a civilian-majority ruling body.
A group of 235 fighters from a faction of a Darfur rebel group that is part of the protest movement were released later on Thursday as decided on the first day of talks.
They were freed from Al-Huda prison in Omdurman, the twin city of Khartoum across the Nile river, an AFP correspondent reported, adding that many relatives had arrived to receive the fighters.
Protest leaders have exerted pressure on the generals since the June 3 raid on the mass sit-in outside army headquarters.
The raid was carried out by men in military fatigues.
The ruling military council insists it did not order the violent dispersal of the sit-in.
At least 136 people have been killed across the country since the raid, including more than 100 on 3 June, according to doctors close to the umbrella protest movement, the Alliance for Freedom and Change.
The health ministry says 78 people have been killed nationwide over the same period.
On Sunday, protest leaders managed to mobilise tens of thousands of supporters in the first mass protest against the generals since the raid.
The mass rally had been seen as a test for the protest leaders' ability to mobilise crowds after the generals imposed a widespread internet blackout and deployed security forces in the capital's key squares and districts, its twin city Omdurman and other towns and villages.
On Thursday hundreds of students from several schools in three towns - Madani, Gadaref and Sinnar - staged spontaneous protests chanting "civilian rule, civilian rule", witnesses said.
The students also chanting "blood for blood, we don't want compensation," a catchcry of the protest movement calling for those guilty of killing demonstrators to face justice.
Protest leaders have further upped the pressure on the generals by calling for a similar mass protest on 13 July, to be followed by a nationwide civil disobedience campaign a day later.
The campaign, if observed, would be the second such agitation since the 3 June raid.
The first, held between 9 June and 11 June, paralysed the country, hitting an already dilapidated economy hard.