Assassins mounted on scooters gun down two secular politicians. Roadside bombs cripple soldiers in the mountains. An ambush this week leaves eight soldiers dead — five with slit throats.

Among the countries of the Arab Spring, Tunisia is widely considered to have the best chance for a successful democracy, with Egypt in an increasingly bloody and complex crisis after a military coup, Libya beset by competing armed groups and Syria deep in a grinding full-scale war without apparent end. But the emergence of an armed al-Qaida-linked jihadi group in the deep wooded valleys and caves of a mountainous region near the Algerian border threatens to derail the tenuous transition.

The Jebel Chaambi mountains, established as a national park to protect curved-horned Barbary sheep and endangered species of gazelles in Tunisia’s southwest, has now become a haven for al-Qaida in North Africa. It is a remote region of unpaved streets, smugglers and strong distrust of the government, despite a stepped-up military effort to defeat the militants.

The stakes are high for this North African nation, whose educated, mostly middle-class population kicked off revolutions around the Arab world in 2011, and which is on the cusp of completing a constitution written by Islamist and secular parties working together.

The government ascribes the mounting violence to a jihadist group linked to al-Qaida’s branch in North Africa, including militants who fled the French military intervention in Mali. That threat is jeopardizing Tunisia’s delicate balance, exacerbating the climate of distrust between political parties and enraging many Tunisians who don’t think the moderate Islamist government is doing enough to take them down.

The unrest is challenging security services too underfunded and overstretched to fight a major terrorist threat, one that could also lead to attacks on Europe and undermine the democratic prospects of the Arab revolutions.

“Tunisia could become like Somalia. Other countries have the economic resources to fight terrorism but we have nothing,” Gen. Rachid Ammar, then the head of Tunisia’s army, warned at the end of June. “I see in Tunisia today signs that make me afraid and keep me from sleeping.” He resigned shortly after those comments.

The source of this fear is lurking in training camps hidden in Jebel Chaambi national park at the tail end of the Atlas Mountains that stretch across North Africa. It also hides in nearby cities and towns where smuggling, unemployment and resentment of the central government hold powerful sway.

After a roadside bomb blew the leg off a soldier patrolling the national park in April, Tunisia sent hundreds of soldiers to search for the militants in Jebel Chaambi. Two months and 10 explosions later, the army declared the mountain cleared, at a cost of three lives, 27 wounded and dozens arrested in the surrounding area — none of them part of the estimated 30 jihadists hiding there.

What the army did find, including documents, identification cards, food and weapons stashes, pointed to a well-organized group with ties to Al-Qaida’s North Africa branch across the border in Algeria and even farther afield — and with support from the local population in nearby Kasserine. The ambush Monday that killed eight soldiers on the mountain also points to the group’s resilience.

Sgt. Mokhtar Mbarki searched the area for weeks, said his wife, Najat Rteebi, and there “they would find boxes of supplies, including pasta and cooking oil” clearly purchased locally. Mbarki was killed by his own men in a late-night friendly-fire incident in June that his 38-year-old wife, heavily pregnant and with three other children, said has not been adequately explained by authorities.

“Kasserine has always been a rebel region and the attitude of the population has always been one of disobedience,” said Samir Rahbi, a local activist with the left-wing Popular Front coalition. “They sympathize with anyone who rebels and this link of blood and regional ties is more important than the interests of the state.”