The Turkish parliament on Friday passed a stripped down version of its controversial homeland security bill that has enraged the opposition, after a 16-hour debate that lasted all night.
Critics fear the draconian legislation, which in the last weeks caused several fist-fights in parliament, will encourage the arbitrary arrest of protesters and turn the country into a police state under President Recep Tayyip Erdogan.
Out of 231 deputies present in parliament where the ruling Justice and Development Party (AKP) holds the majority, 199 voted for and 32 against.
The government had, in an attempt to compromise, put only a limited version of the bill up for vote.
Sixty-nine articles have been approved but the remaining 63 have been sent back to a parliamentary committee for further discussion.
However the articles voted on Friday include some of most contentious measures, including jail terms for protesters who carry Molotov cocktails and other such weapons.
It also permits police to use firearms to prevent an attack in a public place or against people using Molotov cocktails and similar weapons.
The article indicates that the police should use a firearm "with the aim of rendering the attack ineffective".
But human rights activists say it lacks safeguards stipulating that the use of lethal force should be a last resort to protect life.
The law also envisions up to three-year prison sentences for protesters carrying insignia, signs or wearing uniforms resembling those of "illegal organisations" or for those who unfurl illegal banners or shout banned slogans.
It provides for a three to five-year prison sentence for anyone who conceals or partially conceals their face during a demonstration or public assembly that "turns into propaganda for a terrorist organisation".
The minimum sentence for offenders who resort to violence, or carry any kind of weapons will be four years.
The law also gives the police the power to detain people for up to 48 hours without authorisation of a prosecutor, and gives regional governors the power to instruct police to act without prior judicial authorisation.
The law needs to be signed by Erdogan in order to come into effect.
Erdogan, a strong advocate of the homeland security law, said it would be pushed through "by any means" after opposition parties resorted to delaying tactics.
The president, co-founder of the AKP party, weathered massive anti-government protests against his rule in 2013 when he was serving as prime minister. The heavily-handed police tactics earned Turkey strong rebuke from its Western allies.
Opposition parties united in their criticism of the new package during a tough session in the parliament, with the Republican People's Party (CHP) party vowing to take it to the top constitutional court.
"There are no winners but losers. Freedoms and democracy will lose," CHP lawmaker Akif Hamzacebi said.
"I believe that the blow dealt to the constitution and law will be reversed by the constitutional court," he said, in comments published in local media.
The pro-Kurdish People's Democratic party (HDP) called it a "dark law" which snubbed freedoms.
"You are flying very high. Your wheels are full of air. We will puncture your tyres," HDP's lawmaker Hasip Kaplan said in reference to AKP's domination.
The CHP lawmaker Sezgin Tanrikulu labelled it a "fascist" law in a message on Twitter.
Erdogan -- who has been in power for over 12 years, first as premier and now as president -- has become increasingly accused of taking Turkey down an authoritarian path.