July 9, 2015 12:12 PM EDT

Correction appended, July 14.

Just before noon on June 26 in the Tunisian resort city of Sousse, a young man calmly pulled an assault rifle from inside the parasol he had used to conceal his weapon. Standing on a sunny beach, he then opened fire. In a half-hour rampage before he was shot dead by police, 23-year-old Seifeddine Rezgui killed 38 people, 30 of them British tourists. The Sousse attack was the deadliest terrorist incident in Tunisia’s modern history. It followed another recent attack; on March 18 two gunmen stormed the Bardo museum in Tunis, killing 22 people—most of them tourists.

Rezgui appears to have received logistical support from other terrorists—­perhaps linked to the Islamic State of Iraq and Greater Syria (ISIS). He and the two Bardo gunmen had slipped across the border to Libya to train in terrorist camps there in January, a senior Tunisian security official told the Associated Press on June 30. Rezgui’s family and neighbors in the small inland town of Gaâfour struggled to explain to reporters how or when the young student became radicalized.

In post-revolutionary Tunisia, however, stories like Rezgui’s are becoming less surprising. The North African country may be the Arab Spring’s closest thing to a success story, but Tunisia is gaining another less hopeful reputation—as the world’s biggest contributor of foreign fighters to the conflict in Syria and Iraq. As many as 3,000 Tunisians have left to join ISIS and other extremist groups since March 2011, according to the Soufan Group, a New York City–based security firm. Hundreds have returned to Tunisia, and officials worry that there are many more like Rezgui, who are all too ready to bring the conflict home with them.

How did Tunisia go from the birthplace of the Arab Spring to the wellspring of fresh ISIS recruits? The answer is that many of the complaints that triggered the country’s Jasmine Revolution—a stagnant economy, endemic corruption, youth unemployment—still linger. Disenfranchised young Tunisians have become easy pickings for ISIS recruiters.

One such target was 31-year-old Jabeur Amami. An engineering graduate, Amami was unable to find a job after the ­revolution and began spending hours in his local mosque in Sidi Bouzid, an impoverished town just 177 km south of Gaâfour, where Rezgui grew up. It was in Sidi Bouzid’s main square that 26-year-old street vendor Mohammed Bouazizi set himself alight in December 2010, sparking a wave of protests across the region. Soon after, Islamist parties flourished in Tunisia, capitalizing on the widespread sense of disillusionment that followed the revolution. Amami’s sister Hayet, a social activist, says radical preachers in Sidi Bouzid would distribute flyers and hold classes after prayers to teach young people about Islam. “In reality, it was a process of brainwashing,” she says.

On July 4, 2014, just a few days after ISIS proclaimed its new Islamic state, Hayet woke up to discover that her brother had left the family’s home during the night. He had gone to Syria to join ISIS. But while there, Amami became disillusioned with jihad, concluding­ that many of the militant groups were working for their own gain rather than to defeat Syrian dictator Bashar Assad. When he returned to Tunisia on Sept. 7, authorities arrested him at the airport on charges of belonging to a terrorist cell. In the hope that she can prevent other young people from following her brother’s path, Hayet has set up initiatives that help un­employed graduates find jobs.

Some Tunisians say the government has not done enough to tackle recruiters or to prevent would-be jihadists from leaving the country. On April 17, Interior Minister Najem Gharsali said his ministry had prevented 12,490 Tunisians from traveling to combat zones in Iraq, Libya and Syria since March 2013. The recently elected secular government, plagued by economic hardship and political instability on its borders, has said it will do more to combat extremism. But unless it can deliver a more promising future to the young people of Tunisia, the anger that once sparked the country’s democratic revolution could just as easily derail it.

Correction: The original version of the story incorrectly described the graffiti in photo No. 7. It memorializes fighters who died helping to overthrow the ruling Tunisian government in 2011.

Write to Naina Bajekal at naina.bajekal@time.com.

EDIT POST