ON MARCH 31st two members of DHKP-C, a Marxist revolutionary group, strolled into Istanbul’s main courthouse disguised as lawyers and armed with guns and hand grenades, and took a prosecutor hostage. Hours later the prime minister, Ahmet Davutoglu, boasted that security forces had conducted a “successful” operation, killing both gunmen. No matter that the prosecutor, Mehmet Selim Kiraz, had been killed too. Three days later 166 websites, including Twitter, Facebook and YouTube, were blocked for publishing images of Mr Kiraz held at gunpoint by his killers. Only when they complied with a court order to remove the pictures did they come back online.

Such crackdowns have become routine under Recep Tayyip Erdogan, the Islamist president, who calls social media “the worst menace to society”. He sometimes claims social media are being manipulated by an unnamed global “mastermind” trying to overthrow him and his Justice and Development (AK) party. A foreign diplomat in Ankara, the capital, says Mr Erdogan is creating imaginary enemies to stoke artificial crises and justify repression.

At the top of Mr Erdogan’s list of foes is Fethullah Gulen, a Sunni cleric based in Pennsylvania with whom he once made common cause against army tutelage in the early days of AK rule. He has since patched things up with the generals, and now claims Mr Gulen’s followers in the security forces and judiciary fabricated evidence for an alleged coup plot, known as Sledgehammer. (Coincidentally, on the same day that Mr Kiraz was being taken hostage, all 236 suspects in the plot, most of them army officers, were acquitted.)

Mr Erdogan has aired similar claims about a corruption probe into his inner circle, revealed in December 2013. Thousands of alleged “crypto-Gulenist” public servants accused of establishing a “parallel state within a state” have been sacked or demoted. More than 70 people have been investigated or convicted for “insulting” Mr Erdogan since he became Turkey’s first popularly elected president last August.

Reforms passed by AK during its first two terms in power, from 2002 to 2011, are being rolled back. A new security bill permits police to shoot at demonstrators and detain suspects for up to 48 hours without a court order. It also increases internet censorship. If Mr Erdogan succeeds in attempts to rewrite the constitution to give himself what he calls a “Turkish-style” executive presidency, it would concentrate power in his hands. Then, says Kadri Gursel, a prominent critic, “Turkey will slide into a one-man dictatorship”.

To push through constitutional change, AK must win at least two-thirds of the seats in parliamentary elections on June 7th. Whether it will is not clear. The main opposition, the secular Republican People’s Party (CHP), is unlikely to gain much. But the pro-Kurdish Peoples’ Democracy Party may reach the 10% vote share needed to take seats in parliament. AK’s list of candidates includes Mr Erdogan’s son-in-law, Berat Albayrak, who has previously worked for a pro-AK conglomerate, Calik. Other protégés are also running for safe seats. But Mr Davutoglu’s influence is palpable as well. This suggests that Mr Erdogan’s grip over AK may be loosening.

A silent power struggle between president and prime minister was evident when they clashed over the conduct of peace talks with Abdullah Ocalan, the imprisoned leader of Turkey’s autonomy-seeking Kurds. Mr Erdogan wants to link any concessions towards Kurds to backing for his executive presidency. Mr Davutoglu, AK insiders say, wants the issues to remain separate because he too wants to keep Mr Erdogan’s power in check.

Many worry that Mr Erdogan’s obsession with an executive presidency could drive him to new extremes. In the past he has invoked sectarianism by targeting the Alevis, who practise a liberal form of Shia Islam, to shore up AK’s Sunni base. His recent diatribes against Iranian and Shia influence suggest he may resort to such tactics again. “No other leader has used religion to polarise the public in this way,” says Levent Gultekin, a pundit and former Islamist. Who knows what other illiberal measures he might consider acceptable?