IT BEGAN with a grove of sycamores. For months environmentalists had been protesting against a government-backed plan to chop the trees down to make room for a shopping and residential complex in Istanbul’s Taksim Square. They organised a peaceful sit-in with tents, singing and dancing. On May 31st riot police staged a pre-dawn raid, dousing the protesters with jets of water and tear gas and setting fire to their encampment. Images of the brutality—showing some protesters bloodied, others blinded by plastic bullets—spread like wildfire across social media.

Within hours thousands of outraged citizens were streaming towards Taksim. Police with armoured personnel carriers and water cannon retaliated with even more brutish force. Blasts of pepper spray sent people reeling and gasping for air. Hundreds were arrested and scores injured in the clashes that ensued. Copycat demonstrations soon erupted in Ankara and elsewhere. By June 3rd most of Turkey’s 81 provinces had seen protests. A “tree revolution” had begun.

In fact these protests are not just about trees. Nor is Turkey really on the brink of a revolution. The convulsions are rather an outpouring of the long-stifled resentment felt by those—nearly half of the electorate—who did not vote for the moderately Islamist Justice and Development (AK) party in the election of June 2011 that swept Recep Tayyip Erdogan, Turkey’s combative prime minister, to a third term. The most popular slogan on the streets was “Tayyip Resign”. Millions of housewives joined in, clanging their pans in solidarity and belying government claims that the protests had been pre-planned rather than spontaneous.

Rainbow nation

It took 24 hours for Mr Erdogan to respond—whereupon he called the protesters “louts” who were acting under orders from “foreign powers”. The wave of unrest evidently caught his government off guard. “The limits of its power have now been drawn,” said Kadri Gursel, a columnist for the daily Milliyet. By June 5th at least three people had died and thousands of others had been hurt; students referred to their bruises as “Erdogan’s kiss”. The Istanbul Stock Exchange fell by as much as 12% on June 3rd, before recovering slightly the next day. Barack Obama’s administration expressed “serious concerns”.

Who are the protesters who have created the biggest political crisis in a decade of Mr Erdogan’s rule? Many are critics of Turkey’s huge urban-development projects, favoured by a government that wants to pep up the slowing economy with infrastructure spending. The schemes include a third bridge over the Bosporus that will entail felling thousands of trees (and was to have been named after an Ottoman sultan who slaughtered thousands of Alevis); a huge new airport for Istanbul; and a canal joining the Black Sea to the Sea of Marmara. Environmentalists are appalled.

But, contrary to Mr Erdogan’s efforts to portray the protesters as thugs and extremists, they cut across ideological, religious and class lines. Many are strikingly young; but there are plenty of older Turks, many secular-minded, some overtly pious. There are gays, Armenians, anarchists and atheists. There are also members of Turkey’s long-ostracised Alevi minority, who practise a liberal form of Islam and complain of state discrimination in favour of the Sunni majority. Each group added its grievances to the litany of complaints.

What unites them is a belief that Mr Erdogan is increasingly autocratic, and blindly determined to impose his views and social conservatism on the country. The secularists point to a raft of restrictions on the sale of alcohol, liberals to the number of journalists in jail, more than in any other country. Thousands of activists of varying stripes (mainly Kurds), convicted under Turkey’s vaguely worded anti-terror laws, are also behind bars. “This is not about secularists versus Islamists, it’s about pluralism versus authoritarianism,” commented one foreign diplomat.

Mr Erdogan’s peevish reaction to the tumult vindicated his critics. He accepted that the use of tear gas had been overdone, and told police to withdraw from Taksim Square. This let thousands gather peacefully a day later. But as the protests gained momentum across the country he poured oil on the flames. The national spy agency would be investigating the mischief, he vowed. He lashed out at social media, especially Twitter. These, he said, were “the greatest scourge to befall society” (in the city of Izmir, on the Mediterranean coast, 29 people have been arrested on the grounds that their tweets incited violence).

The Taksim project would go ahead, Mr Erdogan insisted. He made only a small concession, saying it might house a museum not a shopping arcade; scenting the mood, many retailers are anyway pulling out of the plan.

As for claims that new restrictions on alcohol constituted an infringement of freedom, he dismissed them as nonsense. The measures were for the public good. Besides, “anyone who drinks is an alcoholic”, he said, “save those who vote for AK.” In reply, someone tweeted that if drinking alcohol makes you an alcoholic, then being in power makes you a dictator. To many, Mr Erdogan sounded like the Turkish generals who used to meddle because they knew what was best for the people.

Divide and rule

That wasn’t all. When the main opposition leader, Kemal Kilicdaroglu of the Republican People’s Party (CHP), called on Mr Erdogan to resign, he threatened to unleash “a million of my people” against CHP supporters. He was “suppressing them with the greatest of difficulty”. His departure on June 3rd, on an official visit to north Africa, left some AK party officials sighing with relief. In his absence Bulent Arinc, the deputy prime minister, acknowledged on June 4th that the police had used “excessive force”. “I apologise to the environmentally conscious people who were subjected to violence,” he added, the first hint of regret from the government (but which appeared not to extend to protesters with other motives). Abdullah Gul, the president, had already declared that, in a democracy, every citizen’s view deserved respect.

Mr Erdogan’s response was a perfect example of the polarising manner in which he has governed in recent years. Buoyed by three successive election victories, in 2002, 2007 and 2011—his AK party taking a rising share of the vote—Mr Erdogan has elbowed all rivals aside. He has also managed to neutralise most potential checks on his power, including the army, the judiciary and the media, which he has intimidated into self-censorship.

Erdogan’s image: as frayed as his temper Hints of his intolerance came during his first term, when he tried to criminalise adultery. Faced with a popular outcry (and rebukes from the European Union), he was forced to back down. But during most of his early years, he inspired hope. Sticking to the IMF prescriptions that he inherited, he rescued the economy from the meltdown it suffered in 2001. In the past ten years GDP per person has risen by 43% in real terms, exports have increased nearly tenfold and foreign direct investment has leapt. Turkey is now the world’s 17th biggest economy. Turkey’s robust banks are the envy of their beleaguered Western peers. Although income inequality is worryingly wide, wealth that was once concentrated in the hands of the Istanbul-based elite has spread to the Anatolian hinterland, leading to the rise of a new class of pious and innovative entrepreneurs who are powering growth. Hundreds of new hospitals, roads and schools have dramatically improved the lives of the poor. The OECD, a rich-country think-tank, and the IMF, say Turkey needs more labour-market and other reforms, not least to boost the employment rate among women. Secular Turks might argue that what the country needs is more opera houses and public sculpture. But the majority have never had it so good. This rising prosperity helped to give Mr Erdogan’s government broad nationwide approval. In his first term Mr Erdogan also embarked on sweeping domestic reforms that, in 2005, persuaded the EU to open membership talks with Turkey. He began by neutering the country’s traditionally meddlesome generals. Their influence over institutions such as the judiciary and the National Security Council, through which they barked their orders, has ended. Meanwhile hundreds of alleged coup-plotters caught up in the so-called Ergenekon and Sledgehammer cases—including many generals and a former chief of the general staff—are in jail, awaiting trial.

All this means that Mr Erdogan has been Turkey’s most effective and popular leader since Kemal Ataturk, who founded the secular republic on the ruins of the Ottoman empire. And he is not only popular at home. Unlike most of his predecessors, and supported by the foreign minister, Ahmet Davutoglu, he has embraced Turkey’s Arab neighbours, opening new markets for Turkish contractors and drawing in Gulf Arab investors. Mr Erdogan has also struck an alliance with Iraq’s oil-rich Kurds, a move that has helped pave the way for his bold and ambitious effort to make peace with Turkey’s own Kurds.

The downside

Alas the problems, some of them of Mr Erdogan’s own making, have been mounting. Critics say the judicial reforms that were approved in 2010 have given the government a worryingly big say over the appointment of judges. They point to the Ergenekon case, which has put nearly every serving admiral behind bars. The trial has been dogged with allegations of fabricated evidence. Prosecutors have at times seemed more interested in exacting revenge than justice.

Turkey’s foreign policy is falling apart, victim to Mr Erdogan’s hubris. Even if his salvoes against Israel have pleased the Arab street, they have raised eyebrows in Washington and deprived Turkey of a useful regional partner. His overt support for rebels fighting to topple Syria’s president, Bashar Assad, whom he wrongly predicted would quickly fall, is growing more unpopular. In May twin car-bomb explosions ripped through the town of Reyhanli on the Syrian border, killing 51 people. Turkey said Syria’s secret service was responsible; Syria denies this. But most Turks believe that Mr Erdogan risks dragging their country into war. In the ultimate irony, the Syrian government has warned people not to travel to Turkey, declaring it “unsafe”.

The economy, too, is lacklustre. Growth has fallen to 3%, and unemployment is stubbornly high (see chart). A large current-account deficit makes Turkey vulnerable to a shift in market sentiment that might easily follow the present unrest. Mr Erdogan seems unfazed by all this. Surrounded by sycophants, he is out of touch. Liberals who once supported him are defecting. Secular Turks are incensed by what they see as the steady dilution of Ataturk’s legacy. The introduction of Koran classes for primary-school pupils and the revival of Islamic clerical training for middle schools are examples of creeping Islamisation, they say. For some secularists the planned new restrictions on booze—it cannot be sold in shops between 10pm and 6am, and producers can no longer advertise—were a tipping point. What angered them most was Mr Erdogan’s reference to “a pair of drunks”. “Why are their laws sacred and one that is ordered by religion [Islam] deemed objectionable?” he asked in parliament. He was assumed to be referring to Ataturk and his successor as president, Ismet Inonu. “How dare he insult our national hero? Without Ataturk there would have been no Turkey,” said Melis Bostanoglu, a young banker among thousands marching in Baghdad Avenue, a posh secular neighbourhood on Istanbul’s Asian side.

Politics a la Turca

The protests show that Turkey’s political fault lines have shifted. Scenes of tattooed youths helping women in headscarves stricken by tear gas have bust tired stereotypes about secularism versus Islam. Many protesters were born in the 1990s—reflecting the bulge of teenagers and twenty-somethings in the population. As many women as men were among them.

These people have no memory of the bloody street battles pitting left against right before the army took power in 1980, nor of the inept and corrupt politicians who drove the economy into the ground in 2001. Their views are shaped by Twitter and Facebook; they have higher expectations than their parents. “Being respected is one of them,” said Fatmagul Sensoy, a student. Mr Erdogan “tells us how many children to have [three], what not to eat [white bread] and what not to drink,” Ms Sensoy complained.

Her generation cares as much about animals and the environment as about smartphones. They set up hotlines for stray cats and dogs injured in the clashes and cleared litter after each protest. They fended off vandals who sought to hijack the events. And they marched alongside “anti-capitalist Muslims”, an umbrella group for devout young Turks disgusted by the government’s pursuit of commercial gain at the expense of the environment, and, worse, of its Islamic credentials.

To all of them, Mr Erdogan’s grip seems as unshakable as it is stifling. This is because AK has no credible opponents. The struggle between old-style Kemalists and modernisers led by Mr Kilicdaroglu (an Alevi) continues to hobble the CHP. This may explain the perverse dismay the opposition felt when the government embarked on a peace process with the Kurds, who pose the only serious challenge.

The slavish media have nurtured Mr Erdogan’s sense of infallibility. Eager to curry favour, media bosses continue to fire journalists who criticise the government. The craven self-censorship plumbed new depths when the protests broke out. The mainstream news channels chose to ignore them, broadcasting programmes about gourmet cooking and breast enlargement instead. Infuriated protesters marched on the offices of Haberturk, a news channel. “Sold-out media,” they shouted, as ashen-faced reporters peered out of the windows.

Mr Erdogan intends to stick around. He has long wanted to succeed Mr Gul as Turkey’s first popularly elected president next year (hitherto incumbents have been chosen by parliament). Not only that: he wants to enhance the powers of the post “a la Turca”, as he puts it, enabling the president to dissolve parliament and appoint the cabinet. The protests have put a damper on what was already a fading prospect.

The grove where it all began They may also hobble the effort to create a new democratic constitution, in place of the one written by the generals after the 1980 coup. Crucially, the new document might guarantee the rights of the Kurds. A parliamentary commission has made little progress, because the opposition parties keep throwing up new hurdles—objecting to the removal of references to Turkish ethnicity, for example, and to education in Kurdish. Even before the protests there were signs that Mr Erdogan would defer the constitutional question until after local elections next March. He will now be even warier of alienating his nationalist base by mollifying the Kurds. Such stalling might jeopardise peace. Abdullah Ocalan, the imprisoned leader of the outlawed Kurdistan Workers’ Party (PKK) has been co-operative, renouncing demands for independence, declaring that the days of armed conflict are over and calling on the PKK to withdraw to Kurdish-controlled northern Iraq. Organised Kurdish groups have been glaringly absent from the protests, a sign that they do not want to put the peace talks at risk. But their patience may wear thin. This week there were reports of clashes with the army on the Iraqi border, the first since the PKK announced a ceasefire in March.

Erdogan’s move

For the first time since he came to power, Mr Erdogan looks vulnerable. This may encourage Mr Gul to make a bid for his job: under AK party rules Mr Erdogan cannot run for the premiership again. It is no secret that he would prefer a more malleable ally for the post, to retain his control over AK and the country after he leaves it.

The protests continued as The Economist went to press. But, when they end, there will be many uncertainties. What if Mr Gul decides to stand for a second term as president? Both the CHP and the far-right Nationalist Action Party would support his candidacy, as would Turkey’s most influential cleric, Fethullah Gulen. If he did, and stayed on, Mr Erdogan would be left with neither of the top jobs.

Mr Erdogan may be a natural autocrat but he is also pragmatic. Time and again he has pulled back from the brink. The Taksim rebellion is his biggest challenge so far. If he can swallow his pride and make real amends, Mr Erdogan could yet repair much of the damage. But polarising the country is in his nature. If that continues, a decade of economic and political stability under the AK party may yet come to a pitiful or even tragic end.