Turkish police fired tear gas, water cannon and rubber pellets on Thursday to stop May Day protesters, some armed with fire bombs, from defying Prime Minister Tayyip Erdogan and reaching Istanbul's central Taksim square.
Citing security fears, authorities shut parts of the city's public transport system, erected steel barricades and deployed thousands of riot police to block access to Taksim, a traditional union rallying point and the focus of weeks of anti-government protests last summer.
Erdogan, who warned last week he would not let labour unions march on Taksim, has cast both last year's street protests and a corruption scandal dogging his government since December as part of a plot to undermine him.
The Istanbul governor's office said it had received advanced information that "illegal terror organisations and their extensions" would resort to violence to stoke unrest.
But the security measures failed to deter thousands of people from trying to march, with pockets of protesters playing cat and mouse with police in tear gas-shrouded side streets.
Demonstrators in surrounding neighbourhoods repeatedly tried to breach police lines blocking the way to Taksim, a normally teeming shopping and tourism district which lay virtually deserted and ringed by security checkpoints.
Some 40 people were hospitalised and around 160 detained, according to the Progressive Lawyers Association.
In the working class Okmeydani district, members of leftist groups threw fire bombs and fireworks at security forces, who responded with rubber pellets. Similar clashes erupted in March at the funeral of teenager Berkin Elvan, who had lain in a coma after being wounded in last year's unrest.
Elvan's image was displayed on a giant poster on Thursday as some of the protesters chanted "Berkin's murderer" at police.
"This is a day of struggle. We're not trying to reach Taksim to celebrate but to resist ... We don't want violence and whenever May Day was allowed in Taksim, it was peaceful," said Caglar, 37, a teacher and leftist activist, clutching a scarf and a homemade antacid mixture to protect against the tear gas.
Police also used water cannon and gas to disperse more than a thousand demonstrators in the capital Ankara, where the centre of the city was on lockdown, with a heavy security presence and police helicopters buzzing overhead.
After Erdogan's warning against trying to march on Taksim, the government suggested instead that the May Day gathering should take place at a venue on the outskirts of the city. The unions rejected that idea.
"We will be in Taksim despite the irrational and illegal ban. All roads will lead to Taksim on May Day, and our struggle for labour, equality, freedom, justice and peace will continue," the main unions said in a joint statement on Wednesday.
On the main Istiklal shopping street leading to Taksim, hundreds of police, some in plain clothes, others in riot gear, sat outside shuttered shops. A handful of disgruntled tourists were searched by police as they tried to enter the area, normally one of the busiest in the city of 15 million people.
"This is supposed to be a friendly place for tourists. This is a terrible way to treat visitors," said Mustafa, from Cairo.
The authorities issued a similar ban last year, leading to thousands of anti-government protesters fighting with police as they tried to breach barricades around the huge square, which in previous years was a focal point for labour demonstrations.
That violence was followed by mass protests that spread across Turkey late last May, in one of the biggest challenges to Erdogan's rule since his AK Party came to power in 2002.
"Give up your hope of Taksim," Erdogan said at a meeting of his ruling AK Party lawmakers in parliament last week.
The prime minister has in the past dismissed protesters as "riff-raff" and "terrorists" and pointed to his AK Party's strong showing in elections.
The AK Party dominated the electoral map in municipal polls on March 30, retaining control of both Istanbul and Ankara despite the corruption scandal and last summer's unrest.
But he has faced criticism from abroad, not least from the European Union which Turkey aspires to join, over restrictions on freedom of speech including a two-week ban on Twitter and last summer's police crackdown on demonstrations.
The Washington-based think tank Freedom House downgraded Turkey's press to "Not Free" from "Partly Free" in its annual Press Freedom Rankings on Thursday, saying the country remained the world's worst jailer of journalists.
Want to enjoy 'Zen' reading - with no ads and just the article? Subscribe todaySubscribe now