Recep Tayyip Erdogan, Turkey's abrasive prime minister, made a fool of himself when he tried (and failed) to ban Twitter. Erdogan blames social media for helping to publicise leaked tapes allegedly linking him to a corruption scandal that has rocked his government. He has threatened similar action against YouTube and Facebook. "This thing called social media is currently the worst menace to society," he declared last year during nationwide demonstrations against his increasingly authoritarian rule. Announcing his Twitter ban, he said: "The international community can say this, can say that. I don't care at all." In the event, Twitter use rose 138% in 24 hours as users easily circumvented his ban.

Foolish or not, it would be daft to dismiss Erdogan. His self-confidence is impressive. After three consecutive general election victories and more than 10 years in power, when Turkey's economy grew by 5%, per capita productivity almost doubled, and its regional influence expanded, Erdogan seems to think he has a right to rule. But the shine has gone off his leadership in the past 12 months. His strong leader image has been supplanted, for many, by that of bad-tempered bully.

The immediate spark for the Twitter furore is local elections due a week today, viewed as a key test of Erdogan's enduring appeal. He has been campaigning hard, rallying the rural and urban working-class voters who care little for social media and corruption scandals, but like the ruling AKP's trademark handouts and subsidies. On these results may depend Erdogan's expected run for the presidency in August.

But additional obstacles loom. One is the now open hostility of the influential Sunni cleric, Fethullah Gulen, whose opposition has split Erdogan's conservative base. Another is Turkey's popular president, Abdullah Gul, whom Erdogan hopes to replace. Gul is showing signs of independence. He reacted to the Twitter ban by publicly deploring it – on Twitter. And Gul is no fool.