KAMPALA, Uganda — Protests in Sudan reached a new stage over the weekend, with tens of thousands of people demonstrating in front of army headquarters in Khartoum to demand the departure of President Omar Hassan al-Bashir, who has wielded authoritarian power for three decades.In what may signal a significant development, some soldiers appeared to be throwing their support behind the uprising. They protected protesters from other security forces intent on dispersing them, three demonstrators recounted Sunday afternoon.On at least one occasion, gunfire erupted as uniformed men fought over whether to crack down on the protesters or protect them, two eyewitnesses said in phone interviews Sunday evening.The protests began in December amid food shortages and rising prices, and quickly became a mass movement across Sudan, united by the demand that Mr. al-Bashir step down. Over the weekend, they gained momentum as vast numbers of protesters gathered in front of army headquarters.Mr. al-Bashir’s residence in Khartoum, the capital, is in the same military compound as the army headquarters. Protest organizers estimated that hundreds of thousands of people had gathered, eclipsing earlier demonstrations.On Sunday, the region was bracing for Mr. al-Bashir’s response.The president met with his security council, according to the state news agency, SUNA, which said the council had taken steps to maintain peace and security. The government, it said, is eager to hold talks with all groups to achieve national consensus.The latest protests in Sudan come less than a week after the ailing president of Algeria, Abdelaziz Bouteflika, agreed to resign amid mass demonstrations that were largely peaceful.While Mr. al-Bashir’s hold on power is seen as much stronger than Mr. Bouteflika’s, his position seemed to weaken somewhat over the weekend as the protests gathered strength. The government seemed unsure of how to respond.Protesters and activists were torn between elation and anxiety amid talk of a coming crackdown.“This was a great blow to the government,” said Ibrahim Taha Ayoub, who in the mid-1980s was Sudan’s foreign minister, referring to the weekend’s demonstration.Mr. Ayoub, who has repeatedly attended protests in recent months, said he expected that certain security forces were waiting for an opportunity — or the government’s permission — to attack the crowds in front of army headquarters.One worrisome sign over the weekend was the increased presence in Khartoum of the janjaweed, notorious militias that were blamed for atrocities in the conflict in Darfur. The Sudanese government has reconstituted them as the Rapid Support Forces.“The janjaweed is entering the city,” said one doctor in his mid-20s who attended the protests Saturday and Sunday and did not want to be identified in greater detail because of safety concerns.He said that at checkpoints set up over the weekend, the janjaweed were searching people and vehicles for water and food in a show of force and in an effort to prevent supplies from reaching the protesters.Mr. al-Bashir rose to power in a military coup in 1989 and for much of the time since, he and Sudan have been regarded as pariahs in the West.For a time in the 1990s, Sudan hosted Osama bin Laden. And Mr. al‑Bashir is the only current leader of a nation to be wanted by the International Criminal Court. The court has indicted him on charges of crimes against humanity and genocide, accusing him of playing “an essential role” in atrocities in Darfur, a region in western Sudan.In recent years, Mr. al-Bashir has sought to improve his standing in the West, and in 2017 the United States agreed to lift sanctions against Sudan, citing several promising changes. Among other things, Sudan agreed not to engage in arms deals with North Korea, and to reduce its interference in South Sudan, which after a long civil war became independent in 2011.But that relief has not solved the economic problems in Sudan.“There is nothing in Sudan,” one activist, Hafiz Mohamed, said Sunday in a phone interview from Addis Ababa, Ethiopia.Automated teller machines do not dispense cash, and retirees cannot withdraw their money from banks. Lines at bakeries can be hours long — and often, there is nothing to buy.“If you do have money,” Mr. Mohamed said, “there is not enough flour for bakers to make bread.”It was the price of bread that helped spur the initial protest in the city of Atbara on Dec. 19. Demonstrations quickly spread across Sudan despite often-harsh efforts to suppress them.Over the next three months, government forces killed 60 protesters, according to a report by Physicians for Human Rights, a group based in New York. The group said the police and the country’s powerful internal security agency, the National Intelligence and Security Service, “have entered and conducted attacks on at least seven medical facilities.”In a February television broadcast, Mr. al-Bashir announced a state of emergency, dissolving the federal government and installing military generals in place of state governors.The protests continued, but for a time Mr. al-Bashir seemed to have had some success in slowing their momentum. Protesters were driven off with tear gas, bullets and shotgun blasts.Yet on Saturday, marchers were able to approach the army headquarters, meeting far less resistance than expected. As the protest continued into Sunday, thousands more people streamed in, swelling its numbers.There was some violence and reports of about five deaths — mainly in Khartoum and mainly from gunfire — related to the protests.Still, activists said that the protesters had been met with less violence than some had anticipated, and that the general mood among the protesters was joyous. And some protesters found that once they were near army headquarters, some soldiers shielded them.“The military guys are protecting us from other government bodies,” a participant who gave only his first name, Elsamawal, said by phone on Sunday.Elsamawal, 32, who works in sales, said he watched as an argument unfolded between uniformed soldiers and officers from the National Intelligence and Security Service.“Some of the national security people were trying to stop people from reaching this area, but I saw the soldiers tell them not to touch the protesters, that they are going peacefully, and to let them go,” he said.As Elsamawal spoke, protesters could be heard in the background chanting, “Just fall, that’s all” — a slogan aimed at Mr. al-Bashir.Two other protesters, including the doctor in his mid-20s, said they had seen gunfire erupt as soldiers confronted National Intelligence and Security Service forces intent on dispersing the protesters.But it was unclear how high up the military ranks existed support — or at least sympathy — for the protesters.“Of course the army’s commanders are supporting the president — but the rank and file, the middle ranks, we are banking on them,” Mr. Ayoub, the former foreign minister, said in a phone interview.The Sudanese minister for information, Hassan Ismail, the government’s main spokesman, “commended the way the regular forces dealt with demonstrators who gathered in front of the army general command,” the state news agency reported.