The Tunisian parliament adopted a new anti-terror law overnight Friday aimed at beefing up powers to confront a jihadist threat following deadly attacks but which has been slammed by rights groups as draconian.
The law was adopted after three days of debate by 174 members of parliament with ten abstentions and no votes against, according to an AFP tally.
The president of the assembly, Mohamed Ennaceur welcomed the passing of the "law against terrorism and money laundering", calling it an "historic" moment.
"It's with pride we have arrived at this historic moment ... this law will reassure the citizens," Ennaceur said.
The new legislation comes after a gunman massacred 38 tourists on a Tunisian beach in an attack claimed by Islamic State group (IS) on June 26.
In March an attack on the Bardo museum in the capital Tunis that was also claimed by IS left 21 tourists dead.
The law replaces legislation from 2003 which was adopted under the dictatorship of Zine El Abidine Ben Ali and rights groups say was largely used to crush dissent, in particular then-banned Islamist party Ennahda, which today is one of the main players in Tunisian politics.
While the law was widely supported by both secular and Islamist parties, it has been strongly criticised by rights groups and NGOs.
"This law poses a real threat to rights and liberties in Tunisia," said Amna Guellali, the Human Rights Watch representative in Tunis.
Criminal lawyer Ghazi Mrabet agreed the law was a bad sign, saying: "You can't fight terrorism with regressive reforms."
Critics have condemned the fact the law brings back capital punishment for a number of offences, after a de facto quarter-century moratorium on executions.
The death penalty can apply to anyone who "knowingly murders someone enjoying international protection", a reference to people such as diplomats and international civil servants.
Another article refers to people who commit rape during the course of a terrorism-related crime.
Rights groups also questioned the powers the law accords the authorities, allowing them to detain suspects for 15 days without access to a lawyer or being brought before a judge.
The bill would also make it easier for investigators to use phone-tapping against suspects and make public expressions of support for terrorism a jailable offence.
Advocacy groups have said the law's definition of terrorist crimes is too vague and it fails to adequately safeguard the rights of defendants and could undermine freedoms.
Members of the leftist opposition have also criticised the bill, saying it could be used to stifle popular movements and does not distinguish between protests and terrorist acts.
President Beji Caid Essebsi decreed a month-long state of emergency on July 4, eight days after the shooting at the Mediterranean resort of Port El Kantaoui killed 30 Britons, three Irish nationals, two Germans, one Belgian, one Portuguese and a Russian.
That came after two gunmen attacked Tunisia's national museum on March 18, killing 21 foreigners and a Tunisian policeman. Both attacks were claimed by the Islamic State group.
The country's vital tourist industry has been badly hit and Essebsi has said his country is "at war with terrorism".
"The army, the National Guard, the security forces are doing their duty and the Tunisian people must be secured," he has said. "The country needs to overcome this crisis, everyone must unite."
In a sign of the prevailing tensions in the country, the interior ministry on Friday announced they had foiled a planned terror attack in Bizerte in the North, arresting 16 suspects and killing another as well as seizing arms and explosives.