In the run-up to Turkey’s local elections last weekend, there were predictions that the prime minister, Recep Tayyip Erdogan, would get a slap in the face from the voters, signalling the decline of his administration. Last summer, street protests over his plans to redevelop Gezi Park convulsed the city of Istanbul. His disregard for a 15-year-old boy who was shot in the course of the protests and later died shocked polite opinion. With Mr Erdogan tightening his grip on the media, a deluge of apparently incriminating tapes suggesting corruption and cronyism at the top of the administration flooded the internet.

Yet Mr Erdogan emerged victorious, gaining 45 per cent of the vote, against 38 per cent in 2009. Though this was only a local election, Mr Erdogan took it as a national vote of confidence. His victory speech, in which he hinted darkly at vengeance on his political enemies, was a clear sign that he believed the vote had washed away the allegations against his administration.

The result has two important lessons with significance beyond the borders of Turkey. The first is that the role of social media gets exaggerated by press coverage. Twitter is an elite habit in Turkey: only 15 per cent of the population use it, and they are the news-hungry urban elite. There was outrage when Mr Erdogan tried to cut off access to Twitter and YouTube in the run-up to the election, but the smart urban professionals were never going to vote for him.

The prime minister’s strategy was to ignore the tweeting community and focus on bolstering his support among the two-thirds of the population who are religiously conservative and relatively poor. They came out to vote for him, trusting him to run the economy and steer the country at a time of growing regional uncertainty – the war in Syria to the south, Russian expansionism to the north in Crimea, and the ferment among the Kurdish population both inside Turkey and beyond its borders.

The second lesson is that the great class divide in Turkey and many other countries at the same stage of development is between the educated elite in the big cities – vocal, self-confident and with a direct line to the media – and the majority who look to a leader to lift them from poverty. The result is that the streets of the capital can be controlled by forces hostile to the elected government. This is a trend that can be seen from Moscow to Bangkok and Caracas.

In past decades, governments feared the vengeance of the mob. The city of Paris was laid out with broad boulevards and ample squares to allow police a direct line of fire at revolutionary forces. These days, with the spread of one-man one-vote, governments are more likely to face organised political opposition from the posh people than the ragged masses.

In Moscow, articulate crowds of tens of thousands took to the streets in 2011-12 to protest over Vladimir Putin’s return to power in an apparently rigged election. It is indisputable that Mr Putin has lost the support of the majority in the capital, where incomes far exceed those in the provinces, but these protests, and the accompanying social media coverage, hardly dented his standing overall. His poll ratings never dropped below 60 per cent and now, thanks to seizing Crimea from Ukraine, they are up to 80 per cent.

The Thai capital, Bangkok, has been shaken for the past eight years by a political struggle between the metropolitan middle class (the Yellow Shirts) and people mostly from the neglected provinces (the Red Shirts) who support the ousted prime minister, Thaksin Shinawatra, and his sister, Yingluck, the incumbent. While the Shinawatra family gets the votes, the courts seem to favour the elite opposition. The current focus is a $4 billion (Dh14.7bn) a year rice subsidy that brings in the votes in poor parts of the country but which the opposition says amounts to a dereliction of duty.

In Caracas, the barricades are up around the middle class areas as the opposition mounts protests to capitalise on the fading fortunes of Nicolas Maduro, the luckless successor to the charismatic socialist, Hugo Chavez, who died last year leaving the economy in tatters.

Similar forces are at work in Ukraine, where popular protests against the government in the capital, Kiev, have ebbed and flowed since the 2004 Orange Revolution. But even the success of that revolt in preventing Viktor Yanukovich being elected to the presidency failed to change the electoral arithmetic. He was voted in as president, by quite legal means, in 2010, only to be toppled again in February.

Perhaps Egypt is the most salient example of the disconnect between the capital and the countryside. A networked revolution with massive media support succeeded in removing a president, Hosni Mubarak, who should have retired long before. But subsequent events have proved that the people who spearheaded the revolution were in no way representative of the population at large.

The lessons drawn from these events by Mr Erdogan are simple, but not the right ones. If the electoral arithmetic is on your side, you can ignore the opposition and the people shouting in the street. The purpose of campaigning is to get your core voters to turn out. This principle is called majoritarianism – the tyranny of the majority.

This works for Mr Erdogan now, but it is not sustainable in the long-term. Democracy, to which Mr Erdogan regularly expresses allegiance, is about more than counting votes. It should take into account abiding principles such as freedom of expression and a modicum of respect for the opposition.

At the moment Mr Erdogan sees treachery all around. But what happens when his magic touch deserts him? Turkey’s growth rates are falling, and his economic model of financing consumption with foreign borrowing is looking increasingly risky. One day the electoral arithmetic will turn against him, and he will need to reach out to voters in the centre. That time could be sooner than he thinks.

Alan Philps is a commentator on global affairs

On Twitter: @aphilps