The glaziers and joiners were busy this week, fitting up the offices of Turkey's main opposition party with a new reinforced glass entrance. The night before, with Istanbul city centre thronged with hundreds of protesters and riot police, a mob of 20 men bearing knives and sticks arrived at the branch office of the People's Republican party (CHP). They failed to break in so prised up paving stones and hurled them at the front door.

Two evenings later on Taksim Square, the anti-government protest movement, battered but unbowed after being tear-gassed, beaten and hosed out of the adjacent Gezi Park to make way for freshly planted begonias, adopted a new peaceful ruse. Scores of young people stood silently, many reading books, in an act of civil disobedience against a government they say does not listen to them.

By Wednesday evening the "standing people" on the square were opposed by a handful of other quiet youths, pro-government demonstrators deliberately lining up in front of them.

On the square and at the party offices, streets and parks of Istanbul, the sense is of a city deeply and dangerously divided. There is no suggestion that the government is behind its supporters' street agitation. But Recep Tayyip Erdoğan, the prime minister, has opted in his violent and confrontational response to three weeks of unprecedented unrest to split Turkey in two: a country of "friends and foes", "us and them", "majorities and minorities".

"He sees any form of dissent as treason," said Edhem Eldem, a university historian of Ottoman Turkey.

Protesters in Taksim Square as the anti-government demonstrations entered their 10th day. Photograph: Lam Yik Fei/Getty

Oğuz Kaan, the CHP leader in Istanbul, absolves Erdoğan of any direct blame for the attack on his office. But Kaan added: "The prime minister's speeches are full of wrong words, lies. He's trying to polarise. That's why attacks like this are no surprise. He is kind of promoting this kind of thing."

Throughout June, hundreds of thousands of people from all walks of life have taken to the streets, giving birth to a new media-savvy social movement, while also triggering a formidable and ferocious reaction from Erdoğan himself, whose party also mobilised hundreds of thousands at a string of rallies to demonstrate bedrock support for the prime minister.

Less than 24 hours after ordering the brutal eviction by riot police of the Gezi Park protesters last weekend, a couple of miles away by the Sea of Marmara, Erdoğan performed for two hours in front of some 300,000 supporters who idolise the prime minister, delivering an aggressive tour de force.

"We are here to show our support for our prime minister," said Halime Taş, 20. "We stand behind him in everything he does and says."

Logistically, it was a triumph, underlining the peerless efficiency and organisational capacity of the political machine he controls, the Justice and Development party (AK), which he founded in 2001 and has governed Turkey since the 2002 election.

Ahmet Insel, a political scientist, said: "It's a huge bloc, a huge machine. No one can challenge him. Very well organised, very well funded. And you can't ignore the militancy of the AK."

In a bravura performance tinged with paranoia, whether genuine or feigned, Erdoğan saw "his Turkey" ringed by enemies everywhere – international finance, the BBC, extremists, terrorists, the feeble political opposition, foreign powers. "Those who work against Turkey will tremble with fear," he warned, vowing to hold accountable all those who had supported "terrorists".

He singled out Turkey's middle-class professionals for retribution if they were deemed to be aiding the burgeoning resistance to a government increasingly seen as capricious and intrusive. Doctors, teachers, university staff, hoteliers, bankers, lawyers, journalists and the social media were all warned.

Human rights groups are worried that the government clampdown will turn into an indiscriminate witch-hunt.

Amnesty International's Andrew Gardner, Turkey researcher for Amnesty International, said: "His rhetoric from the start has been negative and inflammatory, provocative. But his speeches have increasingly turned not only against protesters but also against people who defend the rights of protesters."

On Tuesday of last week, in a move that one lawyer described as "unlawful from beginning to end", 44 lawyers were briefly detained after publicly reading a press statement in support of the Gezi Park demonstrations in the main Istanbul courthouse.

Over the past two weeks, several journalists have also been detained, along with a doctor and two nurses who had been working in a makeshift health clinic near Taksim Square.

There have also been reports of journalists trying to cover the unrest being beaten by police, while some said officers forced them to delete footage from their cameras. Medics were reportedly attacked by the police as they were trying to treat injured protesters.

"They shot six rounds of tear gas at our clearly marked field hospital," said one paramedic. "They aimed directly at us. If that's not an attempt to hinder our work, I really don't know what is."

The German Hospital, just off Taksim Square, also came under attack from police using tear gas and water cannon when protesters sought shelter there. "It's a serious crime to attack health facilities," said the paramedic, who wished to remain anonymous. "It's a breach of human rights regulations."

Riot police fire tear gas to disperse protesters near Taksim Square. Six people were killed and some 4,000 injured in the fierce clashes. Photograph: Sedat Suna/EPA

The Turkish health ministry also threatened to start court proceedings against volunteer doctors and nurses.

According to the Istanbul Bar Association, 883 people have been detained in the city since the protests began, including a group of peaceful protesters doing nothing but standing in Istanbul's main Taksim Square in a powerful act of civil disobedience. The majority have since been released, but the number of people still in police custody is unclear.

"He's really very angry with a lot of people," Emma Sinclair-Webb, Turkey researcher at Human Rights Watch, said of Erdoğan. "It is worrying that he vows to go after them one by one."

The government has also vowed to crack down on social media. Last Monday, the interior minister, Muammer Güler, said: "We are working on the social media. We believe we need to do some legal regulations there."

While the deputy prime minister, Hüseyin Çelik, insisted that "nobody should expect a ban on social media", the government launched an investigation into the 5m or so tweets posted in relation to the protests, scouring the internet for what it called "provocateurs".

But the hardline response only seemed to embolden rather than frighten. Responding to the government's threats to hunt down cyber-offenders, the left-wing Turkish hacking group Redhack immediately said it would take all responsibility for tweets deemed "provocative" by the authorities. "We would take the blame with pleasure," it said.

"We have posted all tweets and hacked thousands of people's computers. Don't take on the innocent ones, we are here," it tweeted. "All accounts that retweet Redhack, write about Redhack, or organise the resistance, were hacked by us."

On 5 June, 29 people were detained for messages they had posted on their Twitter accounts about protests. While all of them were released, some fear that the government will tighten censorship of shared content on the internet.

"The AK has turned from victim to oppressor," said Insel. "For the past three years, the government has become increasingly authoritarian. It seems clear that Erdoğan has reached his own limits on democratisation."

If the crackdown was aimed at striking fear among those members of the public sympathetic to the protesters and deterring wider participation, the impact so far has appeared limited, with the resistance using humour, irony and satire to laugh at the government to dispel the apprehension.

Forcefully removed from the park that was the crucible of the protests, the dissidents have staged evening debates all week in district parks across Istanbul, discussing local and national politics and how to proceed.

Ayşe Çavdar, a journalist who has taken part in the protests, argued that the demonstrations had fundamentally changed the understanding of participatory democracy in Turkey.

"After [the military coup in 1980] the state slapped labels on all of us, and we acted only within the confines of these labels. We were afraid of each other, distrusted each other. The Gezi protests have erased all of them.

"In my opinion we owe Tayyip Erdoğan a debt of gratitude," she added. "He brought us all together, he turned every inch of the pavement, every tree, and every flower into a political arena. We are very happy about what is happening in Turkey."

Undeterred by violence or the threat of arrests, protesters have found ways of circumventing heavy-handed government crackdowns, countering police brutality and state force with peaceful, creative ways of protesting, such as the now-ubiquitous "standing people" all over Turkey, satire and their own independent media.

'Erdem Gunduz’s protest was both an affront and a question for the authorities: beat him? Why? He’s just standing there. Leave him alone? Then he wins, doesn’t he?' Photograph: Vassil Donev/EPA

"The protests have created a new civil society and unprecedented solidarity amongst people in Turkey," Çavdar explained. "People think of each other, take responsibility for each other."

On Tuesday night, hundreds of people met in Abbasağa park in the seaside district of Beşiktaş to discuss strategy and the concerns of protesters involved in the movement. They used silent hand signs to show agreement and disagreement – so as not to wake local residents living near the park.

"We need to talk to the shopowners and retailers in Sultanahmet," one speaker said, referring to the city's busy tourist area. "With the drop in tourism, they are afraid for their businesses. We need to show them that we are on their side."

In other parks, people decided to volunteer for free summer schools for children from poorer neighbourhoods and to set up centres for street children.

Similar meetings were held all over the city, with lists and times for meetings distributed via social media, their number growing every day. District debates are planned in 35 Istanbul parks on Thursday evening.

Whether this flowering of social activism coalesces into a more focused, organised political movement or simply peters out is unclear. What is certain is that the participants remain frustrated and uncowed by Erdoğan's uncompromising response.

"It's mostly about culture, about values," said Koray Çalışkan, a political scientist who is heavily involved active in the protests. "Erdoğan has been so powerful for 10 years that he believes his own stories now. Until Gezi Park there was a real fear. Now we've passed that boundary and people don't care."

Despite comparisons with the Arab spring or the "colour revolutions" in post-Soviet Europe, the Turkish events are unique: the uprising is not aimed at toppling a government or against a dictatorship, nor fuelled by economic grievances. The protesters are not calling for free elections because they are already free, and Erdoğan has won the last three with a rising share of the vote.

Rather, the protesters are rebelling against traditional Turkish paternalism, the prime minister's preaching about lifestyle choices (ranging from abortion rights to dietary choices of which bread to eat and how much salt to add to one's food). His attempts to personally micro-manage the proposed demolition of one inner-city Istanbul park to make way for yet another shopping centre was merely the spark that lit the fire of protest.

"How can a whole society become a prisoner of the will of one person, of one person's mood?" said Insel. "We want to be heard. We want to be respected. It's a cultural and a libertarian struggle."

He describes Turkey as a "random democracy" where rights, liberties, and choices can frequently depend on the whim of the most powerful man in the country.

"Erdoğan is a control freak under the influence of too much success," said Eldem. "He rules by force of numbers. In the past most would have considered this entirely legitimate. But Gezi Park is about the feeling that things cannot work that way any more. It may open the way to a new politics."

Whether hope or fear prevails, it is not yet clear if the past three weeks have produced any winners. But there is a growing consensus that the prime minister, while strong and popular, has already lost a lot, that Erdoğan's crude and intolerant attempt to force an end to the revolt has left him tarnished.

Turkey's prime minister, Recep Tayyip Erdogan, has turned 'an insignificant protest in a scrubby little park into a national emergency.' Photograph: Adem Altan/AFP/Getty

His big strategic aim has been to rewrite the Turkish constitution to turn a parliamentary democracy into a presidential system vested with sweeping new powers and that he would become that first executive president.

Most analysts say that ambition is now doomed, that the AK may forfeit 10% of its electoral support. Erdoğan is regarded as having lost much of his international lustre. Insel adds that he is no longer seen at home as someone who can handle a crisis with aplomb. And there may also be a knock-on effect on the fragile prospects for historic peace talks to end Turkey's 30-year-old Kurdish insurgency.

"Erdoğan wants to remodel society, not only economically, but morally and culturally, to leave his mark on society," said Insel. "He has reached his limits."