Algeria's security services have been rocked by the arrest of the anti-terrorism chief and sackings of top officials in recent weeks, as a behind-the-scenes power struggle intensifies.
The oil-rich North African state has been ruled since 1999 by President Abdelaziz Bouteflika, but concerns have been growing over how much longer he can stay in power.
The 78-year-old won re-election last year but appeared only once during the campaign, in a wheelchair after suffering a stroke in 2013.
Experts say Bouteflika and his allies - especially powerful army chief of staff Ahmed Gaid Salah - are consolidating power ahead of a potential succession battle.
There are fears such a struggle could spark instability in a country already beset by a persistent Islamist insurgency, outbreaks of inter-ethnic violence and a squeeze on public finances from falling oil prices.
Experts say the recent moves have tilted the balance in favour of the tight circle around Bouteflika and Salah at the expense of a rival faction centred on the DRS state intelligence service and its chief, 76-year-old Mohamed Mediene.
"The battle is coming to an end and president Bouteflika has defeated the shadowy power" of the DRS, which had emerged as a "state within the state", said political science professor Rachid Tlemcani.
The latest move came with the unprecedented arrest on 27 August of Abdelkader Ait-Ouarab, also known as General Hassan, who served for two decades as Algeria's anti-terrorism chief.
Until 2014, the general had led an elite unit under the DRS that had carried out special operations - including a 2013 assault on the In Amenas gas plant after it was seized by extremists in a crisis that left 38 hostages dead.
Local media reported that General Hassan had been arrested at his home in Algiers and was being held in a military prison 50 kilometres (30 miles) south of the capital.
|"The battle is coming to an end and president Bouteflika has defeated the shadowy power"
- Prof. Rachid Tlemcani
El-Watan newspaper described General Hassan, a close ally of state intelligence chief Mediene, as "collateral damage" in the struggle between the presidency and DRS.
His arrest came several weeks after the firings of three security chiefs including two considered close to Mediene, who has led the DRS since 1990. Known here as Toufik, he has never appeared in public.
Both the head of the counter-intelligence unit and chief of presidential security were replaced with little explanation except for reference to an "accident" in which shots were fired at one of Bouteflika's residences.
As commander-in-chief and defence minister, Bouteflika has the power to sack any security official and el-Watan said recent months had seen many forced into retirement.
"Many other officers in these services, notably those who made names for themselves in the fight against terrorism, found themselves on the list of those eligible for retirement, including some between the ages of 38 and 50," it wrote.
In the last 18 months, the DRS has already lost many of its powers - including the right to carry out judicial probes into corruption - and some of its responsibilities have been transferred to the army.
There have also been unconfirmed reports that the powerful GIS Special Intervention Group, a hundreds-strong tactical sub-unit of the DRS, has been dissolved.
For political analyst Rachid Grim, there can be no doubt what has been happening.
"Now the presidency has taken power," he said.
The intrigue comes at a time when Algeria is facing a slew of challenges.
An Islamist insurgency that reached its height in the 1990s has subsided but militants continue to carry out regular attacks, including an ambush by al-Qaeda's North African branch in July that killed at least nine soldiers.
There have also been sporadic outbreaks of deadly fighting between Berbers and Arabs in the country's south, with 22 people killed in July in the worst violence in years.
And while Algeria's economy has been growing steadily in recent years, the collapse in oil prices over the last year has hit the OPEC member hard.
Algeria generates 95 percent of its export revenue and 60 percent of government income from hydrocarbons and is projecting a major budget deficit this year.
For now the country can count on financial reserves garnered during its boom years but economists have warned widespread reforms are needed to ease its dependence on energy exports.