TUNIS - The 2011 revolution that toppled Tunisia's regime has awoken extremism in the country after decades of repression, turning it into a target for attacks and a key exporter of terrorists.
Analysts say the current state of affairs is a result of the legacy of ousted president Zine El Abidine Ben Ali's 23 years of iron-fisted rule, as well as Tunisia's porous borders.
"Ben Ali's monopolisation of the religious sphere and neglect of socioeconomic issues opened the door to radicalisation," the Carnegie Middle East Centre says in a report.
"These factors, combined with the disillusionment of the youth and the mishandling of Salafists after the revolution, have resulted in escalating violence in Tunisia and the export of terrorists to Syria, Iraq, and Libya," it said.
According to the United Nations, more than 5,500 Tunisians, mostly aged between 18 and 35, have joined extremist organisations in conflict-riddled Syria, Iraq, Libya, Yemen and Mali.
Many are fighting in the ranks of the Islamic State group, which claimed three major attacks in Tunisia last year alone, two of them killing a total of 60 people, all but one of them foreign tourists.
Dozens of policemen and soldiers have also been killed since the 2011 revolt while two opposition politicians were assassinated in 2013.
The Carnegie report - "Market for Jihad: radicalisation in Tunisia" - said the fall of Ben Ali's regime "created a vacuum that allowed radical groups to preach their ideas and recruit new members".
During Ben Ali's rule thousands of his political opponents as well as Islamists were imprisoned and many others forced into exile, giving him a free hand to bolster repression.
"Ben Ali strengthened state security's control over mosques and imposed legal restrictions on the hijab and Islamic dress. Political, or even any public, expression of religiosity was considered a threat," the report said.
Five years since his overthrow, Tunisia is "paying the price of Ben Ali's mistaken policies towards religion," said a senior security official who declined to be named.
Many Tunisians "turned to social networks and foreign religious satellite television stations, particularly from the mid-1990s, thus provoking the expansion of Wahhabi thought," he added.
Wahhabism has been accused of fuelling deadly Sunni extremism around the world, including the murderous drive of IS militants.
Tunisia's struggling economic situation worsened after the revolution - unemployment now stands at more than 15 per cent - and analysts say this has fuelled radicalisation.
In a report dedicated to Tunisia's "porous borders", the International Crisis Group think-tank drew a correlation between the rise of jihadism and contraband across the frontiers with Algeria and Libya.
Smuggling operations have long served as an informal economy in Tunisia, providing a livelihood for many people in poor regions, even before Ben Ali.
But with conflict raging across the border in Libya, the frontier has also served as a gateway for jihadists and weapons.
"The war in Libya... has had security repercussions and armed groups in border areas have conducted attacks against members of the National Guard, army and police," said the ICG.
"The aftermath of the Tunisian uprising and of the Libyan war has provoked a reorganisation of contraband cartels... thereby weakening state control and paving the way for far more dangerous types of trafficking."
The think-tank warned the situation could eventually lead to "the emergence of a so-called Islamo-gangsterim".
This, in turn, "could contribute to the rise of groups blending jihadism and organised crime within contraband networks operation at the borders or worse, to activate co-operation between cartels and extremists." The Carnegie report notes that jihadists have succeeded in wooing recruits in Tunis suburbs and farther away in the hinterland of Tunisia, saying the feeble economy helped feed extremism.
The Tunisian Institute for Strategic Studies said in a recent study that there is a "clear link on the map of jihadist Salafist expansion" between "social exclusion and the economy".
Omeyya Naoufel Seddik, analyst with the Tunisian Centre for Humanitarian Dialogue, says some people have joined IS seeking "social promotion".
He said these recruits believe that the jihadist group could provide them with a "better standard of living".
According to the UN, extremist recruiters can earn between 2,700 and 9,000 euros (S$4,817-S$14,000) for each recruit, depending on the competence of the fighter.
But Tunisia, which the ICG says has turned into a "strategic hinterland and a recruitment base for terrorists", did not become radicalised overnight.
Tunisians have fought in Afghanistan, Bosnia and Chechnya, and two of them, posing as reporters, assassinated in 2001 anti-Taliban figure Ahmad Shah Massoud in Afghanistan.