The Turkish parliament has agreed to give the police sweeping new powers - but only after weeks of long debate, punch-ups between MPs and sit-in protests.
The controversial new security bill is expected to be approved by President Recep Tayyip Erdogan.
The police will have the right to conduct stop-and-search, detain people for up to 48 hours without court orders and use firearms against demonstrators carrying petrol bombs or other "injurious weapons". Critics say that could mean a firecracker or a simple slingshot.
Demonstrators who are masked, for example with a scarf, could face up to five years in prison. Governors - who are appointed by the government - would be given the right to order police investigations.
The government argues the measures are needed for security and protection from violent protests and are in line with European standards. The opposition says the bill, if approved, is bound to turn Turkey into a police state.
It comes at a sensitive time for Turkish domestic politics. A general election will be held on 7 June and peace talks to end three decades of Kurdish insurgency have faltered recently, as splits emerged between the governing AK Party and Mr Erdogan over how to proceed.
The Kurds are particularly wary of the new bill, saying it could be used specifically to target them. It was introduced after pro-Kurdish protests in October, in which almost 50 people died.
Mehmet Ersoy, an MP in the ruling, Islamist-rooted AKP, says those protests convinced the government to adopt extra police measures in order to "stop provocations".
The bill would have a positive impact on the peace process, he told the BBC.
"Let's see who really wants peace. Let's take the masked vandals with Molotov cocktails off the scene," he said. "We just want to stop the violence."
However, Ertugrul Kurkcu, an MP from the pro-Kurdish party HDP, does not share that optimism.
"If the gendarmerie, who will now be under the interior ministry, or the police rely on the powers granted to them and try to intimidate, pressurise or use violence against people, that will damage the peace atmosphere. There will no longer be a suitable climate for peace talks - neither politically, nor psychologically," he said.
Law and order drive
The main opposition CHP party plans to launch a constitutional court challenge to the bill soon.
Akif Hamzacebi, a CHP member of parliament, argues that the bill's main aim is to crush public dissent and prevent a "second wave of unrest similar to the Gezi events" - the anti-government protests that took place in June 2013.
"The government is extending police powers in order to control dissent. However, such bills fuel more dissent," he said.
Amnesty International has condemned the bill, and the US State Department has expressed concern.
State department spokesman Jeff Rathke said: "We believe curbs on freedom of assembly weaken rather than strengthen democratic societies."
Last week the Turkish parliament also passed a bill that would allow the government to ban access to websites "threatening lives, public order or people's freedom" even before seeking a court order.
Mr Erdogan tolerates little dissent and more than 70 people have faced legal action for insulting him since he became the country's president last August.
Those who have been prosecuted include a 13-year-old for a Facebook post, several students, satirical cartoonists, a Miss Turkey beauty queen and an actress.