Bouteflika replaced Mediene "in line with the constitution" and using his prerogatives as president and defence minister, it said in a statement.
The presidency said Mediene had "retired", but provided no further details.
The 76-year-old better known as General Toufik was a powerful man who saw five presidents and a dozen prime ministers come and go, prompting some to call him "rab dzayer" or the "God of Algeria".
Mediene had never appeared in public, but on Sunday his picture was published for the first time by a local newspaper, En-Nahar, showing him in a suit and tie and wearing sunglasses.
Toufik was the last serving general from among a line of top officers behind a crackdown against the radical Islamic Salvation Front (FIS) after it swept to victory in elections in the early 1990s.
The army stepped in to annul the vote, sparking an Islamist insurrection and a brutal civil war that lasted nearly a decade and killed 200,000 people.
During that time, DRS head Mediene became one of the most powerful men in the oil-rich North African state.
His successor General Bachir, an engineer by training, was one of his key deputies during the civil war. He served as a security adviser to Bouteflika from September 2014.
The announcement of Mediene's replacement came a day after Bouteflika's chief of staff confirmed the arrest last month of Algeria's former counter-terrorism chief.
Abdelkader Ait-Ouarabi, a close ally of Mediene and better known as General Hassan, had himself previously headed the DRS and was at the centre of the army's fight against Islamists for two decades.
The daily Al-Watan revealed the arrest of General Hassan at the end of August, saying he was detained at his home and taken to Blida military prison, south of Algiers.
- 'State within a state' -
General Hassan's arrest came several weeks after the sacking of three security chiefs including two considered close to Mediene -- the head of counter-intelligence and the chief of presidential security.
Experts have said the arrest and sackings are part of a behind-the-scenes power struggle between Bouteflika and the powerful DRS.
Analysts say the balance has tilted in favour of the tight circle around Bouteflika and his army chief of staff, Ahmed Gaid Salah, at the expense of a rival faction centred on Mediene.
Political science professor Rachid Tlemcani said: "The battle is coming to an end and President Bouteflika has defeated the shadowy power" -- a reference to the DRS.
Echoing many, he described the intelligence service as "a state within a state".
Political analyst Rachid Grim has said "now the presidency has taken power", in an account of Bouteflika's actions.
Over the past 18 months, the DRS had already lost many of its powers -- including the right to carry out judicial probes into graft -- and some of its responsibilities have been transferred to the army.
These developments come as Algeria faces a raft of challenges.
More than two decades after the civil war, the army continues to be at the forefront of a campaign against jihadists.
Armed Islamist groups are still active in the country, where in 2013 a four-day siege by Islamists of In Amenas gas plant left 38 hostages dead, all but one of them foreigners.
Algeria also faces a financial crisis, compounded by weaker oil prices. The central bank said last week that foreign reserves had fallen 11.1 percent in the first six months of 2015.
The 78-year-old Bouteflika, who has ruled Algeria since 1999, has the power to sack any security official or force him into retirement.
--------------------------------------------------------------------------------------------------------------------------------
The presidency said Mediene had "retired", but provided no further details.
The 76-year-old better known as General Toufik was a powerful man who saw five presidents and a dozen prime ministers come and go, prompting some to call him "rab dzayer" or the "God of Algeria".
Mediene had never appeared in public, but on Sunday his picture was published for the first time by a local newspaper, En-Nahar, showing him in a suit and tie and wearing sunglasses.
Toufik was the last serving general from among a line of top officers behind a crackdown against the radical Islamic Salvation Front (FIS) after it swept to victory in elections in the early 1990s.
The army stepped in to annul the vote, sparking an Islamist insurrection and a brutal civil war that lasted nearly a decade and killed 200,000 people.
During that time, DRS head Mediene became one of the most powerful men in the oil-rich North African state.
His successor General Bachir, an engineer by training, was one of his key deputies during the civil war. He served as a security adviser to Bouteflika from September 2014.
The announcement of Mediene's replacement came a day after Bouteflika's chief of staff confirmed the arrest last month of Algeria's former counter-terrorism chief.
Abdelkader Ait-Ouarabi, a close ally of Mediene and better known as General Hassan, had himself previously headed the DRS and was at the centre of the army's fight against Islamists for two decades.
The daily Al-Watan revealed the arrest of General Hassan at the end of August, saying he was detained at his home and taken to Blida military prison, south of Algiers.
- 'State within a state' -
General Hassan's arrest came several weeks after the sacking of three security chiefs including two considered close to Mediene -- the head of counter-intelligence and the chief of presidential security.
Experts have said the arrest and sackings are part of a behind-the-scenes power struggle between Bouteflika and the powerful DRS.
Analysts say the balance has tilted in favour of the tight circle around Bouteflika and his army chief of staff, Ahmed Gaid Salah, at the expense of a rival faction centred on Mediene.
Political science professor Rachid Tlemcani said: "The battle is coming to an end and President Bouteflika has defeated the shadowy power" -- a reference to the DRS.
Echoing many, he described the intelligence service as "a state within a state".
Political analyst Rachid Grim has said "now the presidency has taken power", in an account of Bouteflika's actions.
Over the past 18 months, the DRS had already lost many of its powers -- including the right to carry out judicial probes into graft -- and some of its responsibilities have been transferred to the army.
These developments come as Algeria faces a raft of challenges.
More than two decades after the civil war, the army continues to be at the forefront of a campaign against jihadists.
Armed Islamist groups are still active in the country, where in 2013 a four-day siege by Islamists of In Amenas gas plant left 38 hostages dead, all but one of them foreigners.
Algeria also faces a financial crisis, compounded by weaker oil prices. The central bank said last week that foreign reserves had fallen 11.1 percent in the first six months of 2015.
The 78-year-old Bouteflika, who has ruled Algeria since 1999, has the power to sack any security official or force him into retirement.
--------------------------------------------------------------------------------------------------------------------------------