NAIROBI, Kenya — Sudan’s prime minister was released from detention on Sunday, four weeks after he was ousted in a military coup, as part of a deal to end a bloody standoff that led to dozens of protester deaths and threatened to derail Sudan’s fragile transition to democracy.
The prime minister, Abdalla Hamdok, was set free after weeks of tense negotiations with Lt. Gen. Abdel Fattah al-Burhan, the army chief who ousted him from power on Oct. 25.
Appearing in public for the first time since he vanished into house arrest, Mr. Hamdok appeared alongside General al-Burhan on Sunday afternoon at a hastily organized ceremony at the presidential palace in the capital, Khartoum.
The two men signed a deal that provided for Mr. Hamdok’s immediate reinstatement as prime minister, the release of all political detainees and a return to a power-sharing arrangement intended to steer Sudan toward democratic elections as early as 2023.
Seated beside the two leaders was Lt. Gen. Mohamed Hamdan, a ruthless and ambitious paramilitary commander who is seen by many as one of the most powerful people in Sudan, one of the largest countries in Africa.
But the exact terms of the deal were unclear, with much left unsaid between leaders who until hours earlier were bitter foes. And there were early signs that it would be wholly rejected by the angry young Sudanese who have massed in the streets to protest the military’s dominance.
In recent weeks, the security forces have shot dead 40 protesters and wounded hundreds of others in a brutal crackdown on the wave of anti-coup demonstrations that have swept Sudan’s major cities, according to Sudan’s largest doctors’ group.
The protesters called for the reinstatement of Mr. Hamdok, a technocrat who became prime minister in 2019 after tumultuous protests that ousted Sudan’s longtime dictator, Omar Hassan al-Bashir. Mr. Hamdok shared power with military leaders as part of a transitional arrangement intended to lead toward the country’s first free election in decades.
But as news of the political agreement filtered out on Sunday, some protesters gathered at the gates of the palace where Mr. Hamdok was signing the deal with General al-Burhan, apparently infuriated that he had compromised with the military they despised.
Inside the hall, Mr. Hamdok, dressed in a suit and tie, appeared remarkably phlegmatic beside the military officers who had imprisoned him at his home for nearly a month. When he accepted the job of interim prime minister, Mr. Hamdok said, “I realized that the road would not be strewn with roses.”
But he spoke only obliquely of his ordeal, preferring to point to the path ahead. “By joining hands, we can all reach a peaceful shore,” Mr. Hamdok said.
In brief remarks, General al-Burhan, who stood up clutching a baton, paid tribute to Mr. Hamdok for his “confidence and trust,” and promised Sudanese citizens that he would continue with the political transition “until your dreams of democracy, peace and justice are realized.”
Under the terms of the deal, Mr. Hamdok would be allowed to form a new government, said a Western official who spoke on the condition of anonymity to discuss sensitive negotiations.
But important points of contention between the two sides have not been finalized, the official said. They included crucial arrangements for sharing power and making key appointments, such as attorney general.
Critics said that they feared the deal would allow the military to retain its decades-long dominance over Sudan, and it was rejected out of hand by the Umma Party, Sudan’s largest, and the Forces of Freedom and Change, a major coalition of civil society and political groups.
In a statement on social media that appeared to signal new political difficulties for Mr. Hamdok, the coalition group said that any compromise with the military was unacceptable. “There is no negotiation, no partnership and no legitimacy for the revolutionaries,” the coalition said.
Since the coup, General al-Burhan has come under tremendous pressure from the United States and other Western countries to change course. The pressure has included freezing aid to Sudan, which is in the throes of a deep economic crisis, and halting debt relief programs worth up to $50 billion.
At the same time, analysts say, the army chief needs to quell discontent in his own ranks. The power-sharing agreement that the military reluctantly signed in 2019, after the ouster of Mr. al-Bashir, had long been fraught with tensions.
But in recent months, the military grew visibly uncomfortable with ceding more power to civilian leaders who could threaten the privileges and economic interests they had accrued over Mr. al-Bashir’s 30 years of rule.
Some officers also opposed the government’s decision to send Mr. al-Bashir to stand trial at the International Criminal Court in The Hague on decade-old charges of war crimes and crimes against humanity over his role in atrocities in the western Darfur region in the 2000s.
If Mr. al-Bashir is convicted of war crimes, military officers who served under him during that period, including General al-Burhan, could also be exposed to charges.
More broadly, though, the military appears determined to ensure that it holds the balance of power as the country moves toward elections planned for late 2023 or early 2024.