Ras Jedir
Tunisian troops stand guard at the country's northern border crossing with Libya, Ras Jedir.Reuters

Tunisia has voted to introduce the death penalty for those convicted of terrorism in the wake of a wave of brutal attacks on tourists in the north African country.

The country's parliament voted on Sunday to introduce capital punishment as a response to two brutal attacks on foreign tourists and fears of rising Islamist militancy.

Last month 38 tourists, mostly British, were shot and killed on the beach in the city of Sousse in an attack claimed by the Islamic State (Isis) but carried out by a lone gunman, Seifiddine Rezgui.

It came just months after the March attack on Tunis' Bardo Museum which killed 21 foreign tourists and a police officer.

After three days of debate the death penalty was voted in 174/0 with 10 abstentions. It comes as the Tunisian authorities have launched a massive crackdown on suspected Islamist militants, arresting thousands of suspects across the country.

Faltering success story

Tunisia is often considered to be the one success story of the 2011 Arab Spring, having made a relatively peaceful transition to democracy. Its first government, the Islamist Ennahda Party was elected following the overthrow of dictator Ben Ali, and was subsequently voted out in 2014.

But the success of its fledgling democratic system comes as thousands of Tunisians have fled to Libya, Syria and Iraq to join the ranks of the IS. At the same time, the country's porous border with Libya has allowed IS fighters to enter the country relatively freely.

Seifiddine Rezgui, the Sousse gunman, had received his training in Libya and was able to travel between the countries freely.

Tunisia has responded to the rising militancy and harrowing attacks on foreign tourists – on which its economy relies – with an increasingly hard-handed police and army response to militancy and the construction of a border fence with Libya.

Repression warning

The introduction of the death penalty has been opposed by some groups including Human Rights Watch, which said that it would "would open the way to prosecuting political dissent as terrorism, give judges overly broad powers and curtail lawyers' ability to provide an effective defence", Reuters reported.

Indeed, critics have pointed out that the law bears many similarities to legislation introduced by Ben Ali in 2003 in order to crush dissent to his dictatorial rule.