There is something almost comic in the way the missteps of the Turkish government turned a small demonstration aimed at preserving sycamore trees in Taksim Square from the developers' bulldozers into the biggest and most widespread popular protest ever seen in Turkey. The Turkish security forces made the classic mistake of being pictured on television and social media publicly assaulting peaceable protesters with water cannon and pepper spray. Just enough violence was used to enrage and provoke while wholly failing to intimidate.
There was a time when brutality by the security forces was easier to keep off TV screens by censorship or frightening journalists and media-owners. But these mechanisms no longer work when people have a multitude of TV channels inside and outside the country to choose from. Running documentaries on penguins, as CNN Turkey notoriously did, simply creates a vacuum of information which is rapidly filled by protesters. The government's version of what is happening becomes self-marginalised and is ignored.
It is astonishing that skilled politicians such as the Prime Minister, Recep Tayyip Erdogan, and those around him should make so many mistakes in such a short time. It is easy to why Zine el-Abidine Ben Ali of Tunisia and Hosni Mubarak of Egypt should have miscalculated popular reaction to repression at the start of the Arab uprisings in 2011, because as rulers of police states their approach to public opinion was to ignore it.
But how did Erdogan fall into the same trap? An obvious explanation is simply the arrogance of those who have held power for too long. They ignore advice and demonise and underrate their critics. There is nothing very Turkish in this. The same was true of Margaret Thatcher and Tony Blair who, like Erdogan, had each won three election victories and were facing an electorate that blamed them for anything that went wrong.
The parallel should be between Turkey and Western Europe, not between Turkey and Middle East states. One of the many reasons why foreigners find Turkey so difficult to understand is that they imagine that its politics have similarities with other Muslim states in the region, which are not there. It is true that Turkey has had four military coups since 1960, which vie with anything that happened in Iraq or Argentina for the cruelty of the repression. In the 1980 military coup 450 people died under torture, 50 were executed and many others disappeared. At least 178,000 people were arrested and almost all tortured, while 64,000 were jailed.
This makes Turkish politics sound like Iraq under the Ba'ath Party or Argentina under the junta. But Turkey never ceased to have elections that, unlike in Latin American and Middle Eastern police states, mattered in the distribution of power. Even at the height of military rule, Turkey never wholly ceased to be a democratic state in which powerful parties stood for election and the outcome was not fixed from above as in Mubarak's Egypt or Saddam Hussein's Iraq.
Foreign commentary on the Taksim Square protests over the last week speaks of the competition between "secularism" and "Islam" in Turkey. But in almost all cases it is evident that the writers have not taken on board what these words mean in a Turkish context. "Secularism" in Turkey brings with it the same intensity of belief as a religious cult, attracting at one time the officer class, the professionals, the civil service, the security service and many of the well educated.
But at the heart of Kemal Ataturk's legacy is not secularism, which appealed primarily to the elite, but a super-heated nationalism that had an appeal to all Turkish social classes, though not to all ethnic communities. Hence the great difficulty Erdogan may have in bringing to an end to the 30-year guerrilla war with the Kurds of south-east Turkey despite the ceasefire agreement that was reached in March.
The Taksim Square protests and Turkey's draining entanglement in the Syrian civil war have brought to an end for the moment talk of a resurgent Turkey emulating the old Ottoman empire in terms of influence in the Middle East and even in the Balkans and around the Black Sea. This always seemed to me to exaggerate the political, military and economic strength of Erdogan's Turkey. The idea of "the new Ottomans" carried hidden dangers that Ankara was slow to understand.
First, what was the region where Turkey was going to exercise its enhanced influence? It was primarily among countries such as Lebanon, Syria, Iraq and Iran, notoriously the most dangerous places in the world for interfering foreign states. The US, at the height of its power, suffered two of its biggest defeats here: the overthrow of the Shah in 1979 and its calamitous occupation of Iraq in 2003-11. But now Turkey was confidently lurching into the same quagmire in the expectation of swift enhancement of its influence.
There is not much talk of "the new Ottomans" these days. Erdogan's gamble that Bashar al-Assad and his government would swiftly collapse has not paid off. Instead Turkey has a raging war beginning to spill across its 500-mile southern frontier with Syria. Syrian leaders have been enjoying themselves by applying Erdogan's criticisms of the Syrian regime to Turkey and demanding that he resign. Turkey has ended up acting as proxy for the US in Syria, something that is highly unpopular in Turkey.
Erdogan may feel good about his easy access to the White House, but he has made some serious enemies in Tehran and Damascus. There is no reason to suppose that they have anything to do with the current protests, but Turkey will have difficulty reaching an accommodation with its own Kurds and the Kurds in Iraq in the face of Iranian opposition.
Turkey is peculiarly ill equipped to get entangled in sectarian and ethnic conflicts now exploding in Syria and Iraq. It has been unable to resolve its own Kurdish issue at home and is unlikely to be able to deal with inter-ethnic and sectarian conflicts abroad. It may not have started out intending to be part of a Sunni Muslim offensive against the Shia or allied to the Sunni monarchs of the Gulf, but it has ended up that way. Its wooing of the Iraqi Kurds and their oil and gas will be forcefully opposed by the Shia in Baghdad and Tehran.
Erdogan's mistakes in dealing with the Taksim Square protests and the failures of Turkish foreign policy are not irretrievable ones. But the weaknesses of the Turkish state and the depth of the political divisions within Turkey are becoming more apparent. The demonstrations are also highlighting failings that had previously been masked by Turkey's economic success at a time when much of Europe is mired in recession. Such impressions are important because the flow of foreign capital into Turkey depends on a sense that the country is stable compared to its neighbours.
Nightly riots in western Turkey, bombs exploding in the south of the country and the possibility of renewed Kurdish unrest in the east is sapping the belief inside and outside Turkey that the country is still one of the world's success stories.