ALGIERS (Reuters) - Algerian President Abdelaziz Bouteflika, who resigned on Tuesday after resisting weeks of protests, established himself by ending a ruinous civil war but came undone over corruption and economic stagnation.

FILE PHOTO: Algeria's President Abdelaziz Bouteflika looks on during a meeting with army Chief of Staff Lieutenant General Gaid Salah in Algiers, Algeria, in this handout still image taken from a TV footage released on March 11, 2019. Algerian TV /Handout via Reuters/File Photo

The 82-year-old, a veteran of Algeria’s war for independence, has rarely been seen in public since a stroke in 2013.

He had sought to fend off the wave of dissent against his two-decade-old rule that began on Feb 22 by reversing his decision to seek a fifth term. But he did not say when he would go, further angering protesters.

Bouteflika submitted his resignation on Tuesday after the army chief of staff demanded immediate constitutional procedures to remove him from office, the APS news agency reported.

In a report on Monday, APS had said Bouteflika would leave before his term ended on April 28. Two private TV channels said on Sunday he could quit this week.

A fighter in the 1954-1962 war to end French colonial rule, Bouteflika became independent Algeria’s first foreign minister and one of the forces behind the Non-Aligned Movement that gave a global voice to Africa, Asia and Latin America.

He championed post-colonial states, challenged what he saw as the hegemony of the United States and helped turn his country into a seed-bed of 1960s idealism.

He welcomed Che Guevara, and a young Nelson Mandela got his first military training in Algeria. Black Panther Eldridge Cleaver, on the run from U.S. police, was given refuge. Cleaver held court in his Algiers safe house with Timothy Leary, the drug-taking high priest of U.S. counter-culture.

As president of the U.N. General Assembly, Bouteflika invited Yasser Arafat to address the body in 1974, a historic step towards international recognition of the Palestinian cause.

By the end of the 1970s, though, Bouteflika had fallen from favor at home and went into exile. He returned to public life when Algeria was being ravaged by a conflict with Islamist militants which killed an estimated 200,000 people.

First elected president in 1999, he negotiated a truce to end the fighting and wrested power from the secretive military-based establishment known as “le pouvoir” (the powers-that-be).

Helped by oil and gas revenues, Algeria became more peaceful and richer. But it remains mired in corruption and political and economic torpor in a region where uprisings brought changes elsewhere.

With a cushion of foreign reserves and a population wary of major upheaval after their civil war, Algeria avoided the Arab Spring revolutions that toppled leaders across the region in 2011.

But protests against poor living standards, the lack of job opportunities and services were common even before the mass protests, and foreign investors are keen for economic reforms that will cut the red tape that often hampers business.

POST-COLONIAL STATES’ SPOKESMAN

Some biographers say Bouteflika was born in Tlemcen, western Algeria, and others give his place of birth as Oujda, just over the border in Morocco.

Aged 19, he joined the rebellion against French rule as a protege of Houari Boumediene, a commander who would later become Algerian president.

After independence, Bouteflika became minister for youth and tourism at the age of 25. The following year he was made foreign minister.

Dressed in the tailored suits and sunglasses fashionable in the 1960s, Bouteflika became a spokesman for states emerging from colonial rule, given added authority by the cachet Algeria had earned from defeating France.

Bouteflika demanded that Communist China be given a seat in the United Nations. He railed against apartheid rule in South Africa.

The invitation to Arafat to address the General Assembly was controversial. Only two years before, Palestinian gunmen took hostage and killed members of the Israeli team at the Olympic Games in Munich. Bouteflika watched from the chairman’s dais as Arafat, a gun holster on his waistband, addressed the assembly in New York.

When pro-Palestinian militant Illich Ramirez Sanchez, better known as “Carlos the Jackal”, kidnapped oil ministers from an OPEC meeting in Vienna in 1975, he demanded to be flown with his hostages to Algiers. Bouteflika was shown on camera embracing Carlos at the airport before they sat down to negotiate the hostages’ release.

RETURN FROM EXILE

When Boumediene died in 1978, Bouteflika lost his mentor. He was replaced as foreign minister and an investigation was launched into financial impropriety. Bouteflika said the allegations were fabricated as part of a political plot.

He left Algeria in the early 1980s and settled in Dubai, where he became an adviser to a member of the emirate’s ruling family. He returned home in 1987 but kept a low profile, refusing offers of government posts.

In the meantime, Algeria was unraveling. The military-backed government annulled a parliamentary election in 1992 that Islamists were on the verge of winning. In the conflict that followed, whole villages were massacred and civilians walking in city streets had their throats slit.

Bouteflika, backed by the military, was elected president in 1999 with a pledge to stop the fighting. Against fierce opposition from the establishment, he gave an amnesty to militants who laid down their arms. The violence declined dramatically.

He won re-election in 2004 and again in 2009, although his opponents said the votes were rigged. Through a series of ferocious turf battles with his security forces behind the scenes, Bouteflika had, by the start of his third term, become Algerian’s most powerful president in 30 years.

He consolidated that power last year by dismissing about a dozen top military officers.

Little is known about his private life. Official records mention no wife, though some accounts say a marriage took place in 1990. Bouteflika lived with his mother, Mansouriah, in an apartment in Algiers, where she used to prepare his meals.

Age and poor health caught up with him. French doctors operated on him in 2005 for what officials said was a stomach ulcer. Leaked U.S. diplomatic cables said he was suffering from cancer. He became weaker after his mother died in 2009.

Bouteflika said in a speech in Setif, in eastern Algeria, in May 2012 that it was time for his generation to hand over to new leaders. “For us, it’s over,” he said.

Months later at the start of 2013, a stroke put him into a Paris hospital for three months. He was seen little in public after returning to Algeria to convalesce.