A 2005 photo shows the In Amenis gas field where Islamist militants took hostages, including Americans still being held, this week before clashing with the Algerian military. (AP Photo/Kjetil Alsvik, Statoil via NTB scanpix)

On June 29, 1992, a gaunt septuagenarian named Mohamed Boudiaf made his first and last trip beyond the capital as Algeria's head of state. A hero of the 1950s war for independence against France, Boudiaf had been handed control of the country only four months earlier. The same cohort of generals who had staged a coup in 1991, canceling Algeria's first fully democratic election and sparking an armed uprising by the Islamists who had won a plurality of the vote, thought Boudiaf might help bolster the military government's popular legitimacy. He did, though in part by challenging the generals for power, firing several of them and threatening to investigate others for corruption.

The new Algerian leader traveled that day to Annaba, along a beautiful stretch of the Mediterranean coast that was once a cultural center of the Roman Empire, to give a speech lamenting the mistrust between Algerians and their military. As he spoke, an officer assigned to his bodyguard shot Boudiaf in the back, killing him. The conspiracy theories – was the assassin motivated by sympathy to the Islamist rebels? an agent of the military putting down their enemy? – took root immediately, and they've never fully been settled.

Boudiaf's murder, committed during the opening months of the Islamist rebellion that soon became a years-long civil war, triggered a war within a war between his successors in the top ranks of the military. Both of those deeply intertwined conflicts, the legacies of which still weigh heavily on Algeria today, are crucial for understanding this week's hostage crisis and its disastrous course.

The group of Algerian generals who had appointed Boudiaf quickly replaced him with a more reliable successor. But their more assertive direct rule also forced them to address a question that was increasingly dividing them: how to deal with the growing Islamist rebellion? They split into two factions: The "conciliateurs," who favored conciliation and negotiation with the opposition to peacefully end the crisis, and the "eradicateurs," who insisted that Algeria could be saved only by destroying the Islamists.

The two factions worked at cross-purposes for years, with civilian leaders announcing national dialogues and peace talks as the military sharpened its all-out assault on Islamist fighters and their suspected supporters. The divide actually strengthened the eradicateurs: Their military campaigns undercut peace negotiations, weakening the government's position and disgracing Islamist rebel leaders who had showed signs of compromise.

As the war dragged on, splits began to emerge between the rebels, as well. Two of the largest groups, the Islamic Salvation Army (AIS) and the Armed Islamic Group (GIA), divided over ideology and tactics. The GIA, more extreme on both, eventually adopted the takfiri belief that Algerian society itself was apostolic, or religiously impure, which it used to justify horrific suicide bombings and other mass killings of civilians. At times, the GIA and the Algerian military seemed locked in a sort of arms race of brutality, with Algeria's middle class and its once-cherished intellectual communities stuck in the middle. Meanwhile, the divisions between the GIA and the more moderate AIS led to open conflict.

In 1999, the conciliateurs within the Algerian government secured a major victory. The military-appointed president announced his resignation, presumably under pressure from the eradicateur-dominated military leadership that had opposed his peace talks. As his replacement, the generals supported a former UN General Assembly president named Abdelaziz Bouteflika, thought to be a fellow hard-liner. He was the only candidate on the ballot. Soon after taking office, Bouteflika shocked his military backers by announcing a referendum on his new peace plan, which included a blanket amnesty for any rebels who agreed to lay down their arms. The national referendum passed with 81 percent, under accusations of fraud. Within a year, the plan had ended Algeria's war.

Not everyone among the Islamists joined Bouteflika's peace plan. The more-moderate AIS rebels disarmed. But much of the GIA leadership rejected the deal, though could not stop the majority of their followers from laying down their arms in return for peace. There was another rebel group, though, that largely resisted the 1999 peace offer: the Salafist Group for Preaching and Combat, which had broken away from the GIA just a year earlier.

As the 2000s wore on and Algerians began to put their civil war behind them, the SGPC  lost public support. Its finances shriveled, and its ranks slimmed down to fewer than 1,000 fighters. One of them was Mokhtar Belmokhtar, a veteran of the 1980s Afghan-Soviet war who is thought to have masterminded this week's hostage crisis at the gas complex in the Algerian desert. But, in those years, Belmokhtar and the SGPC, struggling to stay afloat, turned to criminal enterprises. Belmokhtar became known as "Marlboro Man" for his illicit cigarette trade. One of their favorite tactics, however, was ransoming hostages, sometimes foreigners, for huge pay-offs.

Since the end of the Algerian civil war, two important developments -- both of them outgrowths of those dual 1990s conflicts -- helped sow the seeds for this week's hostage crisis. The first was within the rebel group SGPC, which by 2004 had reached a low point.  A year earlier, it began losing potential donors and recruits more interested in fighting the U.S.-led invasion of Iraq. So SGPC's new leader reached out to al-Qaeda: He wanted to join as their North Africa affiliate.

"Only after prolonged ideological and theological debates, often carried out on Internet sites," the Washington Post's Edward Cody explained earlier this week, did SGPC become al-Qaeda in the Islamic Maghreb. Belmokhtar kept up his for-profit smuggling and hostage-taking and later broke off from the al-Qaeda affiliate to start his own group, but he retained elements of al-Qaeda's fierce rhetoric. He was also now forced to live, and to compete for resources, in an Algerian Islamist militant community increasingly dominated by the al-Qaeda ideology of jihad, rather than the old struggle against the country's military rulers.

The attack on the gas complex this week has some traits of Belmokhtar's old ways, namely the taking of hostages, as well as the new: His group's demands have reportedly included, at various points, an end to the French intervention in neighboring Mali and the release of Egyptian and Pakistani terrorism suspects being held in the United States. Looking over the course of Algerian history, it's hard to imagine that the Islamist political leaders who rose up in 1991 imagined that their successors would one day join a global jihad.

As the crisis unfolded, whether or not Belmokhtar knew, an old split within the Algerian government, the schism between conciliateurs and eradicateurs, was about to reopen. Algeria's foreign minister, and old Bouteflika ally named Mourad Medelci, was in the middle of a phone call with his Irish counterpart, who had called with concern for an Irish citizen held hostage, when Medelci suddenly announced that the Algerian military had begun an assault to take the hostages.

The Algerian military operation launched Thursday appeared to shock the United States, U.K. and Japanese governments. All three, which were monitoring their own citizens being held, quickly announced that they'd been given no prior notice of the attack, a remarkable break with normal diplomatic procedure. The Japanese government publicly called on the Algerian forces to pull back: Such "rescue operations" are typically considered a last resort because they put the hostages at extreme risk. Though we still don't know for sure what happened, initial reports suggest that a number of hostages were killed in the fighting.

The high-risk, low-reward assault can appear baffling from outside Algeria. But, as North Africa analyst Geoff Porter explained at Foreign Policy, Algeria's military has its own logic when it comes to Islamist terrorists, one born of internal and external fights during the 1990s civil war. Porter writes that the result of that internal dispute, despite Bouteflika's peace deal, was that, "The eradicateurs won -- and they still remain in the driver's seat in today's Algeria." In that faction's thinking, "eliminating terrorists is still the only Algerian government's only actionable policy."

Most governments declare, as policy, that they will not negotiate with terrorists. But this leading faction of Algeria's military, driven to anti-compromise zealotry by the civil war, seems to mean it in a way that few others do. The audacious assault that may have killed several hostages shocked Western governments. But in the logic of the Algerian civil war, which ended 13 years ago everywhere but in the minds of the Algerian generals and Islamists who squared off this week in the remote Saharan desert, this was just another skirmish.