Sudan has been in the midst of a political crisis since long-serving ruler Omar al-Bashir was overthrown in April. The military and pro-democracy movement have been locked in a tussle for power that has led to mass protests and killings.
The security forces have used brute force to strengthen the position of the generals. In the worst such case, dozens of people were killed - and some had their bodies thrown into the River Nile - in a crackdown on protesters in the capital, Khartoum on 3 June.
But tens of thousands of protesters returned to the streets a few weeks later to stage the biggest demonstration since Mr Bashir's overthrow. This forced the junta to resume talks on a power-sharing government and an agreement has now been reached.
Here's what you need to know about the crisis.
How did it all begin?
The unrest in Sudan can be traced back to December 2018, when then President Bashir's government imposed emergency austerity measures to try to stave off economic collapse.
Cuts to bread and fuel subsidies sparked demonstrations in the east over living standards and the anger spread to the capital, Khartoum.
The protests broadened into demands for the removal of Mr Bashir - who had been in charge for 30 years - and his government.
The movement reached a climax on 6 April, when demonstrators occupied the square in front of the military's headquarters to demand that the army force the president out.
Five days later, the military announced that the president had been overthrown.
So who took power?
A council of generals assumed power on 11 April but it has struggled to return normality to the country.
The seven-member Transitional Military Council (TMC) is led by Lt-Gen Abdel Fattah Abdelrahman Burhan. The council says it needs to be in charge to ensure order and security.
But the army is not a unified force in Sudan. Paramilitary organisations and various Islamist militias hold some sway.
The military has also faced international condemnation for the attack on protesters on 3 June, with the UK saying the military council bore "full responsibility".
In response, the TMC expressed "sorrow for the way events escalated", saying that the operation had targeted "trouble makers and petty criminals" .
Who are the opposition?
The economic problems brought Sudanese from all walks of life to the streets, but the organisation of demonstrations was taken on by the Sudanese Professionals Association (SPA) - a collaboration of doctors, health workers and lawyers.
The protesters are mostly young, reflecting the country's demographics, but people of all ages have been seen in the crowds.
Women are at the forefront of the demonstrations. A video of a young woman standing on the roof of a car and leading the chants was widely shared on social media.
When the military took power in April, demonstrators stayed put outside its headquarters and insisted that it transfer authority to a civilian administration.
Talks between the ruling generals and the protest organisers, who have come together under the umbrella group Forces of Freedom and Change, initially showed little sign of progress, but they eventually came to an agreement.
What did the two sides agree?
The military and protesters have reached several agreements fleshing out the details of a power-sharing arrangement, with each side trying to overcome suspicion and build a working relationship.
On 4 August they signed a constitutional declaration which will pave the way for the formation of a transitional government. A formal signing ceremony is due to take place on 17 August.
They have agreed on the following:
- Power-sharing will last for 39 months
- Elections to be held at the end of that period
- 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
- Sovereign council will have 11 members (5 civilian and 5 military nominees plus one agreed by consensus)
- 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 other positions will be taken by pro-democracy candidates
- Sovereign council and cabinet members barred from running for election
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 argued that Mr Bashir's regime was so deeply entrenched that it would take time to dismantle its political network and open the way for free and fair elections.
More about the Sudan crisis:
What has the international response to the crisis been?
Most African and Western countries have backed the protesters. But Egypt, Saudi Arabia and the United Arab Emirates are seen to be allies of the junta.
They perhaps fear the protests in Sudan could inspire similar events to take place in their countries.
The TMC's vice-president, Mohamed Hamdan Dagolo, also known as Hemeti, flew to Saudi Arabia in June to meet the crown prince Mohamed Bin Salman, promising to stand with the kingdom against threats and continue sending Sudanese troops to help the Saudi-led coalition in Yemen.
The AU suspended Sudan as a member of the pan-African body after 3 June crackdown, saying it will be reinstated only after a civilian-led transitional authority is established.