CAIRO — Lt. Gen. Ahmed Gaid Salah, Algeria's military chief and a pivotal figure in the ouster of the country's autocratic president this year, died of an apparent heart attack on Monday, according to the state news agency.

Gaid Salah’s death threatens to plunge the gas-rich country — the largest in the Arab world and in Africa — into political uncertainty, coming days after an election marred by pro-democracy protests calling for an overhaul of the political order.

“The death of Gaid Salah is going to lead to a reconfiguration of the political forces,” said Dalia Ghanem, an Algeria scholar at the Carnegie Middle East Center in Beirut.

Gaid Salah, who also served as vice minister of defense, died in a military hospital in the capital, Algiers, according to state radio. He was said to be either 79 or 80, according to local media reports, and although he had suffered heart problems in the past, his death caught most Algerians unawares.

A stalwart of the resistance movement that won Algeria’s independence from France in 1962 after a seven-year war, Gaid Salah was widely viewed as the nation’s most powerful figure at the time of his death. The military, as in other North African nations, plays an instrumental role in society and politics.

For decades, Gaid Salah supported President Abdelaziz Bouteflika, a fellow veteran of the independence war who had ruled Algeria since 1999. But this year, after hundreds of thousands took to the streets to denounce the 82-year-old’s bid for a fifth term in office, Gaid Salah turned against Bouteflika. In March, Gaid Salah took the extraordinary measure of urging that Bouteflika be declared unfit for office.

A month later, Bouteflika was pushed out of office, and Gaid Salah emerged as the primary power broker in the nation, a key Western ally against terrorism and a key political and economic player in the region. Gaid Salah went further, pushing for anti-corruption measures, especially targeting members of Bouteflika’s clique, including the former autocrat’s brother, Said, and powerful intelligence officials.

Gaid Salah also championed fresh presidential elections in the hope that a new elected leader would end the country’s biggest political crisis in decades.

But thousands of Algerians took the streets in anger, declaring the election a sham because all five candidates were former members of Bouteflika’s government. The protesters, known collectively as Hirak, called for a boycott of the vote, which they claimed was intended to preserve Bouteflika’s clique.

Gaid Salah’s death could galvanize the protesters, analysts said.

“This is an opportunity for the popular movement to pressure the civilian leadership for more concessions, such as the immediate release of the political prisoners,” Ghanem said.

Gaid Salah’s choice for president, former prime minister Abdelmadjid Tebboune, went on to win the election by a comfortable margin, though the turnout was 40 percent.

Four days ago, Gaid Salah and Tebboune embraced at Tebboune’s inauguration ceremony. On Monday, Tebboune announced a week of mourning to remember Gaid Salah, who has been temporarily replaced by another senior general, according to state media. 

“For Tebboune, this is, of course, a loss of an ally, but more importantly, with or without this death, the Algerian president is in a very difficult situation,” Ghanem said. “His first major problem is his lack of legitimacy.”

But within Algeria’s powerful military, analysts said, any major shift in views is unlikely.

“This military elite has little interest in making meaningful concessions to Hirak, which wants the army to withdraw from politics,” said Anthony Skinner, Middle East and North Africa director for Verisk Maplecroft, a political risk consulting firm, adding that it is unlikely that Bouteflika’s clique will make a comeback.

But Skinner also cautioned that Algerian politics are notoriously opaque and that competition between rival factions could deepen during this period of uncertainty.

“It is conceivable that turf battles will become more pronounced now that Gaid Salah has gone,” he said.