THE Turkish prime minister, Recep Tayyip Erdogan, has recently been seen sporting a Cossack-style hat like Ataturk’s. Kemalists were horrified. Yet nobody could dispute that Mr Erdogan has been Turkey’s most impressive leader since the great man’s death in 1938. His mildly Islamist Justice and Development (AK) party came to power in 2002 on a wave of popular support and a rejection of decades of inept rule. Mr Erdogan has lifted Turkey out of stagnation and political paralysis and made it an inspiration in its region.

He has chipped away at the generals’ might, improved the rights of women and Kurds, doubled GDP per head, built modern roads and hospitals and empowered the downtrodden. His reforms prodded the European Union into opening membership talks in 2005. Despite worries about a gaping current-account deficit, the economy has slowed but not crashed, unlike others in the Mediterranean.

It was no surprise when AK won a third term of single-party rule in June 2011. Yet a year on Mr Erdogan is being tested as never before. Setbacks include an alleged bout with cancer, a row with the powerful Muslim Gulenist group, escalating Kurdish violence and the war in Syria. He has grown increasingly authoritarian, his judgment perhaps clouded by an ambition to be elected president when the term of the incumbent, Abdullah Gul, ends in 2014.

It is this ambition that critics say is undermining Mr Erdogan’s promises to deliver a new democratic constitution. A parliamentary committee supposed to produce a draft text appears designed to fail. It needs unanimous approval from all its members for every article. “Are the nationalists going to agree to the Kurds’ demands for Kurdish-language education? Of course not,” says Levent Gultekin, a pro-Islamic commentator. Many suspect Mr Erdogan wants the AK party to produce its own blueprint that would boost the powers of the presidency, enabling him to keep running the country after the party’s rules require him to step down as prime minister. Since he does not have a two-thirds majority in parliament, a new constitution would need to be put to a referendum; most polls give AK a big lead.

Still, he is not taking chances. Over the past year he has been increasingly hawkish over the Kurds, scrapping secret talks with the separatist Kurdistan Workers’ Party (PKK) to end their bloody 28-year insurgency. He has reverted to force and the mass arrests of thousands of Kurdish activists. “The bond between Turks and Kurds is growing weaker by the day,” warns Selahattin Demirtas, leader of the pro-Kurdish Peace and Democracy Party.

Media bosses fearful of losing government contracts have sacked critical journalists. At least 80 journalists are in jail, many of them Kurds accused of PKK membership. The government’s intolerance extends to students, 2,824 of whom are in prison, almost a quarter of them charged with “membership of a terrorist group” for calling for free education and other “sins”.

Mr Erdogan’s secular opponents accuse him of reverting to his Islamist roots. Calling for a “more religious youth”, he has proposed to restrict abortions and has reintroduced imam hatip (clerical-training) middle schools. A new curriculum includes optional Koran and Arabic-language classes. Mr Erdogan’s embrace of pious nationalism is calculated to appeal to the far right and to conservative voters. But he may be overplaying his hand. The army’s battle against the PKK has had little effect. Scores of soldiers have been killed this year and the rebels have carried their battle from the mainly Kurdish south-east as far west as Izmir.

Mr Erdogan has taken to blaming the Syrian president, Bashar Assad, for the renewed violence. Mr Assad has ceded control of Kurdish towns along the border to a Syrian Kurdish group affiliated to the PKK. Yet critics point to Turkey’s overt support for the Syrian rebels, which has antagonised not only Mr Assad but also Iran. With scores of generals jailed on coup-plotting charges the army has been cowed into silence. But even Mr Erdogan’s supporters are questioning his Syrian gamble. His gibes at Turkey’s Alevi minority, which has spiritual bonds with Mr Assad’s Alawite sect, have not helped.

With America distracted by its presidential election, Europe bogged down in the euro crisis and the EU membership talks stuck, Turkey’s Western friends have little sway. A recent poll suggests that only 17% of Turks now believe they can join the EU. Many fear their country may be sucked into a regional war. Mr Erdogan is a master at scenting the public mood, but his popularity is falling. His priority ought to be putting his house in order, with a constitution that supports all Turkish citizens rather than his presidential aspirations.