The first president of independent Algeria, Ahmed Ben Bella, died at the age of 96 on April 11, 2012 in Algiers. Above, he appears in 1965. (Getty Images)

Ahmed Ben Bella, a key militant leader in Algeria’s struggle to win independence from France who then served as the first post-liberation president before being deposed in a 1965 coup, died April 11 at his home in Algiers. He was believed to have been 95.

State news media in the North African nation announced the death but did not disclose the cause.

After two years of erratic command, Mr. Ben Bella was ousted by his defense minister, Houari Boumediene, and spent nearly 15 years under house arrest before a long self-exile in Switzerland.

Tall and charismatic, with a powerful physique developed from his youthful infatuation with soccer, Mr. Ben Bella made an energetic return to Algeria in 1990 as leader of an opposition party he started while abroad.

His own aspirations for a comeback were crushed in the 1991 election. But he urged reconciliation during the civil war that erupted after the ruling National Liberation Front (FLN) party canceled elections to prevent Islamists from coming to power.

Although long sidelined from power, Mr. Ben Bella retained clout. He was a devout Muslim, a founding father of the FLN and a rousing voice against imperialism dating from his years as an insurrection leader against the French colonists who had ruled Algeria for more than a century.

A combat veteran of the French army in World War II, he returned home increasingly radicalized by the humiliations suffered by Algerian Muslims under the colonial system. He became attracted to nationalism, guerilla warfare and socialist politics in the 1950s.

After escaping from prison for his role in a robbery, he fled to Cairo and founded the FLN. He enjoyed the protection of Egyptian President Gamal Abdel Nasser, a Pan-Arab nationalist.

Mr. Ben Bella became the chief conduit for Egyptian arms flowing into Algeria. “Every Algerian is a potential guerilla if he could get a gun,” he said at the time. He said he could accept arms from anyone who would offer them, “even the Devil himself.”

In 1956, Mr. Ben Bella and four associates were flying from Morocco to Tunisia when the plane made a forced landing in Algiers and he was taken into custody. Mr. Ben Bella spent the next six years in French prisons as the Battle for Algiers was becoming bloody and protracted.

On March 18, 1962, French and Algerian leaders settled on a cease-fire that also led to Mr. Ben Bella’s release.

Back in Algeria, the economy was unraveling as Europeans fled the country. There were fractures in the provisional government and the military, and a leadership struggle broke out.

William B. Quandt, a professor of politics at the University of Virginia and author of “Revolution and Political Leadership: Algeria, 1954-1968,” called Mr. Ben Bella a “compromise” candidate among the various factions. He had the “prestige” of being in prison, and his populist touch gained him support during the post-in­de­pendence surge in nationalist fervor.

He was elected premier in late 1962 and then president the next year. He sidelined moderates and declared his intention to follow a Marxist economic path that included agrarian cooperatives.

But Mr. Ben Bella squandered his energy denouncing Israel and the United States while doing little to see his programs to completion. He became paranoid — for good reason — about a potential coup.

According to an Associated Press dispatch, Mr. Ben Bella jokingly introduced Boumediene at a formal luncheon as “the man who is plotting to overthrow me.” The president, according to a witness, then leaned in to Boumediene to ask, “How are your intrigues going?”

Boumediene reportedly replied, “Very well, thank you.”

The army deposed Mr. Ben Bella before dawn on June 19, 1965. Boumediene remained in control until his death in 1978. Two years later, Mr. Ben Bella was freed from house arrest.

Ahmed Ben Bella was born reportedly on Dec. 15, 1916, in Marnia, in western Algeria near the Moroccan border. His father, of Moroccan heritage, was a farmer.

Conscripted into the French army, Mr. Ben Bella distinguished himself in combat with an Algerian regiment during World War II. At the battle of Monte Cassino in Italy, he reportedly carried his wounded company commander to safety at great risk and then took command of his battalion.

His ambitions to remain in the army after the war were scotched by a French general who did not believe Muslims had a place as officers in the armed forces. The general called him “intelligent and dangerous.”

Back in Algeria, Mr. Ben Bella was elected to the Marnia municipal council, but his party, the Movement for the Triumph of Democratic Liberties, was declared illegal. This spurred him to join with other nationalists to form an armed insurrectionary group.

To help finance the organization, he participated in an armed robbery in 1949 of the Oran post office. He was soon arrested and sentenced to seven years in jail. A friend smuggled in a blade hidden in food, and Mr. Ben Bella escaped after sawing open the bars of his cell. In Cairo, he joined with other exiled members of the Movement for the Triumph of Democratic Liberties to start the National Liberation Front in 1954.

In 1971, Mr. Ben Bella married Algerian journalist Zohra Sellami. A complete list of survivors could not be determined.

Mr. Ben Bella was described as resolutely formal in manner and brimming with conviction. “I was born a revolutionary,” he once declared, “and will die a revolutionary.”