A month ago Sudan’s pro-democracy movement was battered and in disarray. Protesters were in hiding after paramilitary troops rampaged through the main protest area, looting, raping and shooting dead scores of people. The internet had been shut down. Bodies were being dredged from the Nile.

Then this week the protest leaders and their military foes did something unusual: They sat down in the same room, face-to-face, and within two days hammered out a power-sharing deal to run Sudan until elections can be held in just over three years.

Although the details are still being finalized, the agreement offers the people in one of Africa’s largest and most strategically important countries the fragile hope of a transition to democracy after 30 years of dictatorship under former president Omar Hassan al-Bashir, who was ousted in April.

The protest leaders involved in the negotiations did have to make a significant concession: An army general will run Sudan for the first 21 months of the transition, followed by a civilian for the next 18 months. But many had been skeptical the military would share power at all. Now, the ruling council will have five civilians, five military leaders and an 11th member jointly agreed on.