"President Abdelaziz Bouteflika on Tuesday relieved Prime Minister Abdelmadjid Tebboune of his duties and appointed Ahmed Ouyahia", the president's chief of staff, in his place, the presidency said in a statement published by the official APS news agency.
Bouteflika's National Liberation Front (FLN) and the Rally for National Democracy (RND) headed by Ouyahia together enjoy an absolute majority in parliament after winning re-election on May 4.
In a surprise move three weeks after the vote, the president named Tebboune, who had been housing minister, to the post of prime minister in place of Bouteflika's ally Abdelmalek Sellal.
According to a government source who spoke to AFP on condition of anonymity, 71-year-old Tebboune was dismissed because his "vision was not in line" with that of the president.
The source also cited communication problems between them.
The sacking came days after reports that Bouteflika had sent a strongly worded letter to the premier, demanding he adjust his policies and criticising a decision to restrict imports of many products.
But political analyst Rachid Tlemcani said Tebboune had been seeking to appease "certain oligarchs who belong to the presidential faction" and was the victim of a struggle in the leadership.
Signup to our newsletter and follow us on Facebook and Twitter!
Fellow analyst Rachid Grim said "Tebboune made the mistake of thinking he was protected" by Bouteflika, suggesting that other decision-makers may have pulled strings behind the scenes.
Critics have questioned Bouteflika's ability to govern since a 2013 stroke, but the president's inner circle has insisted he has fully exercised his powers.
Tebboune's successor, 65-year-old Ouyahia, has been a major figure in Algerian politics over the past two decades and has served the president zealously despite sometimes complicated relations.
Algerians have nicknamed him "Mr Dirty Work", after he said he had been given the thankless task of carrying out tough economic reforms demanded by the International Monetary Fund during the country's decade-long civil war.
The North African country weathered the 2011 Arab Spring uprisings with massive spending on wages and subsidies that depleted government coffers.
But a 2014 slump in crude oil prices forced the government to raise taxes and mothball many public projects.
Today, in a country of 40 million where half the population is under 30, one young person in three is unemployed.
The May 4 poll was marred by low turnout amid voter disillusionment over what many see as broken government promises and a political system tainted by corruption.