Bouteflika, 76, has strengthened his hand by appointing loyalists to key posts in the defense and interior ministries, the power centers in Algerian politics.
Intelligence Online, a website based in Paris that covers France's former colonies, said the shuffle, overseen by Bouteflika's brother, Said, was part of "a drive to curb the powers of the country's security establishment" headed by Mediene. It was apparently triggered by international arrest warrants on corruption charges issued Aug. 10 by security authorities, headed by Mediene, against two of his closest political allies -- former energy minister Chakib Khelil and, more importantly, Bouteflika's longtime adviser and friend, Mohamed Reda Hemche.
Mediene has pursued a campaign against Bouteflika's allies for several years, particularly in the state-run oil company Sonatrach, largely conducted under the umbrella of rooting out official corruption.
In the case of Sonatrach, the steady dismissal of senior managers linked to Bouteflika has seriously damaged Algeria's all-important energy industry, which accounts for 98 percent of exports, at a time when it needs to be developing new oil and fields as the older ones are depleted.
The cabinet shakeup, packing key ministries with trusted aides, has been Bouteflika's boldest maneuver since he returned to Algeria July 16 after almost three months in a military hospital in Paris to which he was airlifted April 27 after suffering a stroke.
His frail health and prolonged absence aroused deep concerns among Algeria's 37 million people about the political future of the oil and gas-rich North African state, the region's military heavyweight.
In particular, the country worried about the balance of power between the deeply entrenched military, especially the much-feared DRS, Algeria's Intelligence and Security Department headed by the KGB-trained Mediene -- a relic of post-independence Algeria's flirtation with the Soviet Union -- and the new class of commercially well-connected civilian leaders under Bouteflika.
Given his health problems, many Algerians doubted he could remain as president as his associates sought to restore public confidence in his leadership. The cabinet shuffle apparently was a signal that Bouteflika, first elected in April 1999 after a decade-long civil war with Islamist militants, intends to hang tough in the run-up to the April 2014 election.
Bouteflika, one of the few surviving veterans of the 1954-62 war of independence against the French, has regained control of the Interior Ministry by installing Tayeb Belaiz, one of his closest associates in the Bouteflika clan's inner circle, who will now exert greater control over the security forces.
Ahmed Gaid Salah, another longtime Bouteflika ally, who he promoted to chief of the general staff in 2004, was named deputy defense minister.
Although Algeria is supposed to be a multiparty democracy with regular elections, power resides, as it has since independence, in the hands of the president and the cabal of generals known throughout Algeria as simply"Le Pouvoir," the Power.
Mediene has headed the DRS since September 1990, which makes him the world's longest-serving intelligence chief. The DRS is the core of "Le Pouvoir."
Bouteflika, after three five-year terms, may not run again in April. He wants his younger brother Said to succeed him.
Mediene will do all in his power to prevent that and to install his own man as president.
"The prospect of a dynastic succession was not what the DRS had in mind when it gave the green light for Bouteflika third term" in April 2009, al-Jazeera observed recently.
Jeremy Keegan of London's School of Oriental and African studies, observed that Bouteflika twice tried to replace Mediene with his own people.
One died in a "road accident." He got rid of the other by using the DRS to destroy his reputation and his businesses.
However, Mediene may have suffered a setback with the January seizure of the In Aminas natural gas complex in the Sahara by jihadists, in which 37 foreign technicians were killed when Algerian Special Forces stormed the facility.
Two-thirds of Algeria's population was born after independence and popular support for the National Liberation Front, the military-backed party that's run Algeria since 1962, is visibly waning.