KHARTOUM, Sudan — Sudan’s president was deposed Thursday the same way he came to power 30 years ago — in a military takeover.

Omar Hassan al-Bashir’s downfall, however, did not come with the flying bullets or middle-of-the-night escapes many expected from a leader who survived numerous past crises. Instead, his ouster was precipitated by the biggest peaceful demonstrations in a generation, culminating in a vast sit-in attended by hundreds of thousands in the capital, Khartoum.

The takeover in Sudan capped a season of protest and political churn in North Africa, recalling the 2011 Arab Spring uprisings that toppled autocratic leaders in Tunisia, Egypt, Libya and Yemen. In Algeria, protests that started in February forced North Africa’s longest-serving leader, Abdelaziz Bouteflika, out of power this month.

But amid the euphoria in Algeria and Sudan, demonstrators have appeared more keenly aware of the looming dangers than their counterparts eight years earlier, vowing to remain in the streets until their broad array of demands are met. Protesters at the sit-in in Khartoum received the announcement of new military leadership Thursday with a mixture of disappointment and disbelief.

Sudanese Defense Minister Awad Ibn Auf declared on state radio the establishment of a two-year transitional government administered by the military with him in charge, adding that the constitution was suspended, that a three-month state of emergency was in effect and that a curfew had been imposed. 

State media reported that all political prisoners, including leaders of the protests, were being released from jails around the country. But protesters were angry that their demands for a civilian government were not met and vowed not to end their sit-in.

After the curfew began in the evening, thousands of people remained in the streets, and the army appeared not to enforce the order.

“Did we go through all this trouble for this?” asked Khalid Osman, a protester at the demonstration Thursday. “It’s the same story.”

Sudan, with a population of 43 million, is Africa’s third-largest country by area and occupies a strategic location along the Nile River. Bashir used his geographical leverage to become a regional power broker, presiding over peace agreements in neighboring South Sudan and the Central African Republic, as well as water disputes between Ethiopia and Egypt.

The protests here were sparked in December by price hikes on basic goods, but they also reflected a deep desire for the replacement of Bashir’s regime. Bashir is accused of committing crimes against humanity and genocide in Sudan’s Darfur region and has been indicted by the International Criminal Court.

Hundreds of thousands of Sudanese spent this week in Khartoum’s streets, singing, dancing and waving banners imprinted with hopeful slogans calling for the rebuilding of their country. The protests were initially organized by the Sudanese Professionals Association, a group that drew many doctors, lawyers and students.

The protesters’ demands included Bashir’s prosecution and justice for protesters who had been killed. But many said Thursday that their hope was transformed into anger by Ibn Auf’s speech.

“They just replaced one thief with another,” said Ahmad Ibrahim, a young protester sitting on the ground in the sweltering heat near the sit-in outside army headquarters. “We are going to keep pushing until all of our demands are met.” His friends nodded.

Ibn Auf was a key military leader during Bashir’s suppression of rebels in Darfur and is unlikely to give Bashir up for prosecution. The U.S. government also imposed sanctions against him in 2007 for his role in Darfur.

Western governments responded cautiously to Ibn Auf’s declaration Thursday. The secretary general of the United Nations simply reiterated his “expectation that the democratic aspiration of the Sudanese people will be realized.”

Robert Palladino, the State Department’s deputy spokesman, called on Sudan’s “transitional authorities to exercise restraint and to allow space for civilian participation in the government.”

“The Sudanese people should determine who leads them and their future,” he added. “The Sudanese people have been clear that they are demanding a ­civilian-led transition. They should be able to do so sooner rather than two years from now.”

The Sudanese Professionals Association rejected what it called “a coup to reproduce the faces and institutions that our great people revolted against.”

“Hold the squares and the roads that we liberated by force and courage until the handover of authority to a civilian transitional government that expresses the forces of the revolution,” it wrote on Twitter. “The ones who destroyed the country and killed its people are trying to steal every drop of blood and sweat that our great people shed in the revolution that has shaken the throne of tyranny.”

Through the final years of his rule, Bashir diverted large quantities of the national budget to military spending, while inflation drove up the cost of flour and other basic goods. Sudanese citizens on average are only 19 years old and have never known a president other than Bashir.

Last month, Bashir, 75, announced a state of emergency in response to the protests, giving the country’s security apparatus nearly unlimited authority to disperse the hundreds of thousands of people who had gathered in the streets of Khartoum and other cities.

But after the sit-in began April 6 in front of the Defense Ministry, divisions within the armed forces became increasingly visible as low-ranking officers began to join the protests. High-ranking officers followed by declaring their intention not to disperse the protesters.

Over the past few days, Bashir became increasingly isolated, as coalition partners of his ruling National Congress Party declined to join counterprotests in support of him. 

Fighting between factions of the security forces led to street battles, resulting in at least 11 deaths, including those of six members of the armed forces, the information minister said on Wednesday, citing a police report. Dozens more people have been killed since protests began in mid-December, according to human rights groups.

The International Criminal Court issued indictments against Bashir in 2009 and 2010, cumulatively charging him with five counts of crimes against humanity, two counts of war crimes and three counts of genocide for allegedly directing the fighting in the western Sudanese region of Darfur more than a decade ago. 

Darfur earned Bashir international notoriety for his brutal crackdowns in Sudan’s west and south, areas where darker-skinned Sudanese people are a majority. In the early 2000s, he allegedly recruited ethnic Arab militias known as the Janjaweed into Darfur, where they carried out mass killings, committed rapes and plunged the populace into hunger. 

In 2011, Bashir conceded after a long and bloody civil war with Sudan’s southernmost regions, resulting in their secession and the creation of the country of South Sudan.

Bashir is likely to remain in Sudan under house arrest or seek refuge in one of the countries — such as Saudi Arabia or Egypt — that have allowed him entry in the past without arresting him on behalf of the ICC, according to analysts.

“This is potentially a new dawn for Sudan,” said Rashid Abdi, a regional analyst for the International Crisis Group. “It shows that even the most entrenched dictatorships are vulnerable. The future is uncertain, but there is now a better chance to engineer a viable, inclusive transition.”

The example of Egypt provided a particularly dire warning. After the fall of President Hosni Mubarak in 2011, a rocky two-year transition resulted in a military coup led by Egypt’s current president, Abdel Fatah al-Sissi, and a government more repressive than any in the country’s recent history.

Egypt appeared supportive of Bashir’s ouster Thursday. The two countries had tense relations in recent years because of a border dispute and Sudan’s support for an Ethiopian dam project that Egypt opposes. An Egyptian Foreign Ministry statement pledged Cairo’s “full support for the brotherly choices of the Sudanese people and their free will to shape the future.”

Bearak reported from Nairobi. Kareem Fahim in Istanbul and Carol Morello in Washington contributed to this report.