Algeria is in the grips of political intrigue, as the president nears death and rumors of coup attempts swirl. Now, the unprecedented firing of three top generals is generating fear that a power struggle within the regime will break into the open — unleashing a new cycle of the bloodshed that plagued the country in the 1990s.

The stakes for the oil-rich nation — a key U.S. ally against terrorism — are especially high because of the dramatic fall of oil prices and the rising threat from extremist groups across the border in Mali, Libya and Tunisia. These developments have put the regime on weaker footing in a country still emerging from a traumatic civil war.

On July 16, the night the Muslim fasting month of Ramadan ended, troops flooded the area around the presidential residence of Zeralda amid talk of a possible attack. Rumors flew that it was an attempted coup or an attack by radical Islamists, while some newspapers cited anonymous officials that the whole thing was a hoax.

Then on July 26, the army announced a series of new appointments in key positions, showing that three powerful generals — the heads of counter-espionage, the Republican Guard and presidential security — had all been replaced. The sackings have provoked a flurry of speculation that the country's elites are on the brink of an all-out war.

"These dismissals touch sensitive institutions that risk destabilizing the army amid a difficult regional situation," Louisa Hanoun, leader of the Worker's Party, said in a Monday press conference. "There are too many rumors and too much speculation — the president must speak."

President Abdelaziz Bouteflika, 78, hasn't done much speaking, however, since he suffered a stroke in April 2013 that restricts him to just a handful of heavily scripted television appearances.

He didn't appear in the election campaign he won last year — except to vote in a wheelchair — and his speeches are read by surrogates. Yet he — or at least his entourage — appears to be clinging to power, as generals are fired and the once powerful intelligence services brought more firmly under control. The president is surrounded by a close knit group of advisers, including his brother Said.

"Someone will come and whisper in his ear that this one is not in agreement with you or that one dislikes your family, and he listens," said a former government minister who has since resigned and spoke on condition of anonymity because of the sensitivity of the issue.

"It reminds me of the situation at the end of Bourguiba's reign when officials were appointed in the morning and fired that evening," he said, referring to former Tunisian president Habib Bourguiba, who was overthrown in 1987 after he became senile.

Algeria has always been a closed country run by a small group of politicians and generals, and divisions among the elites have rarely reached the surface. The rumors swirling around the dismissals — and the outcry they provoked from the family of one of the generals — is highly unusual in Algeria, said Kal Ben Khalid, an analyst of Algeria's military who writes the blog The Moor Next Door.

"There is definitely something happening inside the regime, some kind of competition, and it has to be pretty serious to remove three people at once," he said. "There is also probably a move by the president's camp to get some additional institutional depth in the security sector — they are trying to reclaim the deep state."

All this comes at a difficult time for Algeria, with the collapse of oil revenue which makes up 60 percent of the government budget and 97 percent of export earnings. July has been particularly difficult, as ethnic strife between Arabs and Berbers in the oasis town of Ghardaia claimed 22 lives, and around a dozen soldiers were slain in a mountain ambush by radical militants the government said had been defeated.

Issandr El Amrani, North Africa director for the International Crisis Group think tank, said the big fear is that Bouteflika's death will bring a return of social violence.

"There is real anxiety that the succession might not be that smooth and there might be some real power battles within the various power centers of the regime," he said. "It comes at the worst possible time when the state has to deal with looming economic challenges and a deteriorating regional situation."