IS might go but problems would still remain in Tunisia. This article is one of a series exploring the question: What happens after Islamic State?

Tunisia is the North African state with the largest absolute and proportional representation of its nationals within the ranks of the Islamic State (IS). There are, it is claimed, some 7,000 Tunisians enrolled in the movement, compared with an estimated 1,500 Moroccans and between 100 to 200 Algerians.

Many of the Tunisian recruits are located in Libya, despite the fact that Islamic State has been forced out of its stronghold in Sirte. Indeed, Libya is the ideal base, given its political chaos and the wide availability of arms from the stockpiles of the Qadhafi regime, freed up by the Libyan revolution in 2011. As a result, IS fighters have been able to infiltrate Tunisia and launch the Ben Gardane (March 2016), Sousse (July 2015) and Bardo Museum (March 2015) attacks, as well as a devastating attack on the presidential guard in Tunis in December 2015.

Islamic State, however, is not the only extremist Salafi-jihadi actor in Tunisia. Al-Qaeda in the Islamic Maghrib (AQIM) has been able to infiltrate the central portion of the Algerian-Tunisian border around Djebal Chaamba where it has been active for the past four years.

Another movement, based in Libya – Ansar al-Shari’a – has also infiltrated the country and probably been responsible for the assassination of at least two leading left-wing Tunisian politicians. It has, on occasion, collaborated with Islamic State, particularly in the training camp at Sabratha which was destroyed by the Americans in late 2015.

In addition, a dissident faction of AQIM has been active along the Libyan border with Tunisia from where it launched an assault of a major gas facility at Tiguentourin that killed 39 foreign hostages.

It is, therefore, not clear that the disappearance of IS will mean the disappearance of violent extremism from Tunisia. An alternative vehicle for violent hostility exists and, despite the doctrinal disputes, the overriding objectives of IS, Ansar al-Shari’a, and AQIM are similar. Moreover, violent extremist protest will persist because the conditions that generated it – poverty, unemployment, lack of political and cultural authenticity of existing regimes – will persist too.

It is not clear that the disappearance of IS will mean the disappearance of violent extremism from Tunisia

Nor has a driver for the emergence of either IS or AQIM been the failure of a ‘religious state infrastructure’. Both movements emerged in states that couldn’t accommodate or suppress a challenge to their autocracy. Increased religion in the area emerged not because of greater religiosity but because it provided a culturally authentic rallying cry against the rhetoric of the state.

The quest for social and cultural authenticity has become more important as a driver for change than the more mundane but nonetheless real economic and security failures of the state itself.

This dynamic is aided by the tolerance previous regimes have shown for Salafism as an expression of the role of religion within the social order. Its political role emerged only because of the parallel growth of Salafi jihadism as an extremist version of the confrontation between state and social movement in the conquest for control of the state itself.

It is notable, too, that only Libya – an absolute autocracy – experienced a revolution, the implications of which are still unknown. By contrast, Tunisia evolved into democratic transition as a result of its previous status as a liberalised autocracy, as Algeria and Morocco had done so before.

The key to truly marginalising such movements is to ensure that moderate alternatives reflecting Islamic principle, such as the Ennahda movement, succeed.

And that requires such movements to understand and play the political participatory game with appropriate external support whilst recognising that they cannot co-opt or cooperate with their extremist correlates.

That is a lesson that Ennahda in Tunisia and the Justice and Development Party in Morocco have already learned but their companion parties in Libya and Egypt have yet to realise.