The terrorist attack in Algeria last week in which Islamists took dozens of hostages at a remote natural-gas complex is the world’s worst since the attack on Mumbai in 2008, and it puts Algeria in the center of the global jihad. The Algerian regime is an old-fashioned Arab police state with a reputation for fighting jihadists more ruthlessly and efficiently than any other African or Arab regime. It is America’s ally, but a difficult and suspicious partner.

Algeria is geographically the largest country in Africa and the Arab world. President Abdelaziz Bouteflika, 79, has run the country since the 1999 election. He ended a brutal and bloody civil war that began after an Army coup in 1991 that overturned free elections that had been won by an Islamist party. In the violence that followed, at least 160,000 died. Three years later Algerian terrorists hijacked a jet bound for Paris with the intent of smashing it into the Eiffel Tower—the plot that inspired the 9/11 attacks on New York and Washington. The Army reacted with brute force. Bouteflika offered amnesty and initiated reforms to win over an exhausted nation. Now in his third term, he was reelected with 90 percent of the vote in what critics charge was massive vote fraud.

Algeria shares all the same demographic time bombs as its eastern neighbors Tunisia, Libya, and Egypt, which have had revolutions against their police states in the last two years.  Seventy percent of Algeria’s 35 million people are younger than 30, and 30 percent are younger than 15 and thus have no memory of the 1990s nightmare. Unemployment among young men has been a major problem since the 1970s, despite vigorous efforts to reduce it. While women can participate in the workforce and are well educated by regional standards, they too are often unemployed or underemployed. University graduates often find they cannot get jobs commensurate with their education skills. Groups of angry young men can be seen every day in every Algerian city.

The oil and natural-gas economy provides only a small number of jobs. Tourism could produce many more, but the country is not tourism-friendly place, despite beaches, wine, and Roman ruins. Its reputation as a violent and dangerous place discourages Europeans looking for sun, and the regime fears opening the country up to outsiders.

While Bouteflika is the public face of the government, real power still resides with the generals. They avoid the public limelight and are known in Algiers as le pouvoir, the power behind the scenes. In the shadowy world of le pouvoir, the most powerful man is probably the head of the secret police or Mukhabarat. The head of Algerian intelligence, Mohamed Mediène, has a long track record of eradicating terrorist groups using extreme methods. KGB trained and rarely photographed, Mediène has run Algerian intelligence since 1990 and is known for his professionalism and determination. He is also known by his nickname, the God of Algiers, because his power is so pervasive and he seems to answer to no one.

Algeria has the largest army in Africa, over 150,000 strong, a defense budget of more than $10 billion annually, and extensive spy networks across the Sahara. Algerians are fiercely nationalistic after more than a million of them died in the war for independence from France. It remains especially sensitive and nervous about French actions. Algiers opposed France and NATO’s role in Libya, which it blames for starting the Mali mess. But the Algerians did allow French fighter jets to over fly Algerian territory to bomb al Qaeda in the Islamic Maghreb (AQIM) targets in Mali, prompting the attack on its gas facility last week in which dozens died.

Ironically, the attack probably will also push Algiers off the fence about the war in Mali. The generals who run Algeria initially were reluctant to push AQIM out of Mali, fearing that the group would only come back north in to Algeria. Now they have no choice. With a GDP of $260 billion, a large Russian-equipped army, and a ruthless intelligence service, it can do more to fight AQIM than any other African country.

America has had a difficult and troubled relationship with Algeria for centuries. We fought our first foreign war in Algiers to defeat the Barbary pirates. American GIs liberated it from the Vichy French and Nazis in 1942, and John F. Kennedy helped pressure Paris into giving up their colony in 1962, but for most of the Cold War, Algeria was a Soviet ally. George Bush gave the generals support for their coup in 1991 after the fact, and Bush Junior hosted Bouteflika in the White House to gain Algerian support after 9/11 against al Qaeda, but the relationship has always been tense and marked by suspicion.

Hillary Clinton was in Algiers last fall to get support for a U.N. mandate to fight the jihadists in Mali. John Kerry can expect many more trips to Algiers in his time as secretary of state. It won’t be a love affair.