ISTANBUL (Reuters) - Turkish police fired tear gas, water cannon and rubber pellets on Thursday to try to stop thousands of people, some armed with fire bombs and fireworks, from defying a ban on May Day rallies and reaching Istanbul's central Taksim square.

Citing security fears, authorities shut parts of the city's public transport system and deployed thousands of riot police, blocking access to Taksim, a traditional union rallying point and the focus of weeks of anti-government protests last summer.

A protester (L) scuffles with riot police during a May Day demonstration in Istanbul May 1, 2014. REUTERS/Murad Sezer

Prime Minister Tayyip Erdogan, who warned last week against efforts to 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 advance information that "illegal terror organizations and their extensions" would resort to violence to stoke unrest.

Pockets of protesters played cat-and-mouse in several neighborhoods on the fringes of Taksim, a huge square surrounded by stores, restaurants and hotels usually thronged by commuters, shoppers and tourists.

Protesters shoot firecrackers at riot police during a May Day demonstration in Istanbul May 1, 2014. REUTERS

Flag-waving demonstrators, some throwing fireworks and stones, at one point breached barricades in Besiktas, a neighborhood near Taksim on the shores of the Bosphorus, before police forced them back into side streets.

In the working class Okmeydani district, members of leftist groups threw fire bombs and fireworks at police, who responded with rubber pellets and tear gas. 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.

"Berkin's murderers!" shouted one protester as he threw stones at police lines.

Clouds of tear gas also wafted near the Tarlabasi district, a neighborhood of crumbling buildings adjoining Taksim, which is heavily populated by migrants and subject of a government regeneration plan.

A protester flashes a victory sign as fireworks explode near a police water cannon during a May Day demonstration in Istanbul May 1, 2014. REUTERS

UNIONS DEFIANT

Erdogan said last week he would not let unions march on Taksim and the government suggested instead the gathering should take place at a venue on the outskirts of Istanbul. 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 labor, 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. Disgruntled tourists were searched at dozens of police checkpoints thrown up around the square.

A man uses crutches as he walks in front of riot police during a May Day demonstration in Istanbul May 1, 2014. REUTERS/Murad Sezer

"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 labor 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.

A protester, with cream applied to his face to protect against tear gas, reacts during a May Day demonstration in Istanbul May 1, 2014. REUTERS/Umit Bektas

"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 elections on March 30, retaining control of both Istanbuland the capital Ankara despite the corruption scandal and last summer's unrest.

A protester falls on the ground after being hit by water from a police water cannon during a May Day demonstration in Istanbul May 1, 2014. REUTERS

During a visit to Turkey earlier this week, German President Joachim Gauck called on Turkish authorities to protect peoples' right to demonstrate, drawing an angry response from Erdogan, who accused him of interfering in domestic politics.

Other cities in Turkey were calm early on Thursday, although there was a heavy police presence in the center of Ankara.

(Additional reporting by Murad Sezer and Umit Bektas; Writing by Jonny Hogg; Editing by Nick Tattersall and Janet Lawrence)