ALGIERS, Algeria  — Algerian President Abdelaziz Bouteflika stepped down on Tuesday after 20 years in office, and six weeks of massive nationwide protests aimed at pushing him and his much-criticised inner circle from power to create a real democracy in the gas-rich nation.

The announcement followed a sternly-worded call from the powerful army chief for Bouteflika, 82 and ailing, to “immediately” take up his proposal to bow out while respecting the constitution.

There was no immediate word on who would take over from Bouteflika. Under the constitution, the president of the upper house, the Council of Nations, steps in as interim leader for a maximum of 90 days so that elections can be organised.

The official APS news agency said in a full-page headline that Bouteflika had notified the Constitutional Council of his decision to end his mandate. It came a day after an announcement that he would leave by April 28, the official end of his fourth mandate — but after “important” changes were made, giving rise to fears that his entourage would do all to preserve the interests of those who profited from his time in office.

There was also no word about the presidential entourage, including younger brother Said Bouteflika, a top counselor blamed by protesters for widespread corruption in the North African country with a high unemployment rate and drastic gap between the rich and poor.

Army chief Gen. Ahmed Gaid Salah had earlier in the day convened a meeting of the top military hierarchy, making clear the call for Bouteflika to desist had the backing of the military, among the most important on the African continent.

The Defence Ministry communique referred to Bouteflika’s entourage as a “gang” and said it had made “fraud, embezzlement and duplicity its vocation.”

Bouteflika has rarely been seen in public since a 2013 stroke.

His resignation caps six weeks of peaceful protest marches who wanted not just Bouteflika but the entire system to make an exit. It was preceded by a series of moves at the top, including a new government announced days ago and, above all, calls by Gaid Salah for Bouteflika to submit to Article 102 of the Constitution that would declare him unfit for office. Gaid Salah added two more articles called for by protesters, notably Article 7, which stipulates that “the people are the source of power.”

The Defence Ministry statement Tuesday appeared to be a final warning.

Bouteflika came to the presidency after its darkest period, the 1990s Islamic insurgency. After taking power in 1999, Bouteflika managed to bring back stability to a country devastated by killings and distrust.

The insurgency then linked up with al-Qaida and metastasised into a Sahara-wide extremist movement.

As president, age and illness took its toll, and corruption scandals dogged him and associates.

Bouteflika also failed to create an economy that could offer enough jobs for Algeria’s growing youth population despite the nation’s vast oil and gas wealth.

In a country where secrecy surrounds the leadership, it has never been clear whether Bouteflika was fully in charge or whether the powerful army was pulling the strings.