FOR 400 YEARS, says a founding myth common to Turkic peoples from China to the Aegean sea, forebears of the Turks were trapped in the rocky valley of Ergenekon. But one day an ingenious blacksmith learned to melt stone, and a grey she-wolf appeared to lead the tribe from its mountain fastness into the rich plains. Similarly, Kemal Ataturk has for generations been depicted in Turkish schools as a hero who after the first world war rallied a beaten people, repulsed a swarm of invaders and forged a strong new nation. In some ways the story of the rise of the Justice and Development party echoes those tales, with Recep Tayyip Erdogan presented as leading Turkey from a dark era of Kemalist faithlessness into a bright Islamic future.

But now that the party has risen, the story is getting darker. Early in his career Mr Erdogan made a telling remark he was later to regret. Democracy is like a train, he said; you get off once you have reached your destination. Now many of his party’s critics fear that Turkey’s president may be getting close to that goal.

It is not just that Mr Erdogan wants to rewrite the constitution to award himself executive presidential powers. The trouble is that he hardly needs them. Sometimes overtly, but often by stealth and dissimulation, the AK party has spread its tentacles across Turkish society. The courts, the police, the intelligence services, the mosques, the public education and health systems and the media are all, in one way or another, subject to the party’s overweening influence.

The judiciary makes an instructive example. Turkish courts and state prosecutors have never enjoyed a sparkling reputation for neutrality. Mr Erdogan’s own spell in jail in the 1990s, for the “crime” of reciting a poem, represents one of the milder perversions of justice that prevailed before the AK party’s rise. Most Turks cheered as the party undertook a series of reforms, billed as raising Turkish justice to European standards. These changes concerned both the shape and the size of judicial bodies.

In the name of democratising a board that oversees judicial appointments, the AK party expanded its membership, and in the fine print also increased its own powers to select those members. A subsequent move to expand the number of state prosecutors, with the ostensibly laudable aim of speeding up the creaky justice system, enabled the party to appoint thousands more loyalists. The result is a judicial apparatus that, except for the highest courts, increasingly dances to the AK party’s tune.

One example is the use of legislation that penalises insults to the head of state. Turkey’s criminal code has contained such a law since 1926, but it was rarely applied before Mr Erdogan was elected president in August 2014. Opposition MPs say that since then state prosecutors have investigated more than 1,500 people for insulting the president, a crime that can carry a sentence of more than four years. In the first ten months of 2015 nearly 100 people were held in custody on such charges, including cartoonists and journalists, but also teenage boys who had defaced campaign posters or posted Facebook messages. A woman in Izmir was recently sentenced to 11 months in prison for a rude hand gesture directed at Mr Erdogan.

An illuminating case of a different kind is that of Sevan Nisanyan, a 59-year-old linguist and author of an etymology of modern Turkish. Mr Nisanyan is also known for his work to restore a semi-derelict village near Turkey’s Aegean coast, a rare example of careful conservation in a region better known for rampant tourist development. Since January 2014 he has been in prison, sentenced to an astonishing 16 years for various minor infractions of building codes, in a country where illegal construction is commonplace; even Mr Erdogan’s new presidential palace violates zoning laws. Mr Nisanyan is of Armenian extraction, as well as being an outspoken atheist and a critic of the AK party.

Education is another field in which the party’s ideological bent is increasingly evident. As mayor of Istanbul, Mr Erdogan once said he would like every state school to become an imam hatip, a vocational high school with an emphasis on religious training. When such schools first opened in the 1950s, the idea was to supply mosques with preachers. When the AK party took power, they accounted for barely 2% of Turkey’s students. Following a series of reforms, that proportion has risen fivefold, to more than 1m students. Some 1,500 non-religious schools have been converted to imam hatips. Thanks to a well-endowed charity run by Mr Erdogan’s son, these schools are often better equipped than ordinary state ones. Some parents now find they have no choice.

Keep your mouth shut

The most glaring example of the AK party’s creeping annexation of the public sphere, however, are Turkey’s media. By putting pressure on private owners and making vigorous use of laws against incitement, defamation and the spread of “terrorist propaganda”, the party has come to exercise control over all but a handful of broadcasters and news publishers. “I don’t remember any time when it was like this,” says Erol Onderoglu of Reporters Without Borders, a watchdog group. “Hundreds of journalists have been fired or arrested in the past five years, and we expect more every day.”

In recent months the assault on press freedom has involved not just threats and spurious judicial procedures but outright violence. In September mobs attacked the offices of Hurriyet, one of Turkey’s few remaining independent newspapers, after Mr Erdogan criticised its editors on national television. Soon afterwards thugs, several of whom were later found to be AK party members, beat up a popular television presenter, Ahmet Hakan, in front of his Istanbul home, breaking his nose and several ribs. In December Mr Hakan found himself threatened with an investigation for “propagating terrorism” after a guest on his programme said it was a mistake to dismiss the PKK as a terrorist organisation.

A particularly dramatic case of state interference in the press involved the takeover by the government, days before the November election, of Koza Ipek Holding, an industrial group. One of Koza Ipek’s television stations, already confined to the internet after Turkish satellite carriers were asked to drop its broadcasts, showed live footage of law enforcers invading its Istanbul headquarters before abruptly going off air. So far 74 of Koza Ipek’s employees have lost their jobs. Since the takeover the group’s flagship newspaper has typically featured a large picture of Mr Erdogan above the fold.

Figures released by an opposition representative on the board that monitors the state broadcasting service show that the AK party enjoyed overwhelming dominance of air time during the election campaign. Mr Erdogan personally got 29 hours of coverage in the first 25 days of October and the AK party 30 hours. By contrast, the Peoples’ Democratic party, or HDP, was given a grand total of just 18 minutes on air. Even so, it attracted 5.1m votes.

Turkey’s private channels are little better. As the biggest street protests in Turkey’s history erupted in Istanbul in the summer of 2013, the country’s most popular news channel, CNN Turk, ran a documentary on penguins. Like the parent companies of other media outlets, its owner, Dogan Holding, feared government retribution.

According to one media expert in Istanbul, the takeover of Koza Ipek has left just three news channels out of Turkey’s top 40 that are critical of the AK party. Reporters Without Borders now ranks Turkey 149th out of 180 countries on its World Freedom Index, just three places above Russia and 51 down on 2005.

Turkey’s increasingly beleaguered liberals debate among themselves just when the AK party reached a turning point. Some point to 2007, when the army ineptly tried to stop the party from installing its own man (then Abdullah Gul) as president, prompting the AK party to adopt a harder line. Others say the Arab Spring of 2011, which saw the emergence of powerful like-minded Islamist movements in Tunisia and Egypt, may have emboldened the party. And some suggest May 2013, when the violent police response to a campaign against plans for a shopping mall in Istanbul’s Gezi park sparked drawn-out protests across the country. This coincided with the overthrow in Egypt of Muhammad Morsi, whose Muslim Brotherhood government the AK party had loudly cheered.

Mr Erdogan’s furious response to the Gezi protests, say critics, reflected paranoia about a plot to undermine Islamist regimes. He repeatedly blamed the protests on a nebulous “interest-rate lobby,” supposedly bent on weakening the Turkish economy. Other AK party officials hinted at a global Jewish conspiracy. The Gezi protests petered out by the end of that summer, but prosecutions of troublemakers continued. In October last year 244 people received jail sentences of up to 14 months for their part in the protest movement. They included four doctors accused of “polluting” a mosque. The court ignored testimony that they had entered the mosque at the invitation of its imam, using the sanctuary to treat injured people.

The most commonly cited tipping point in both the AK party’s and Mr Erdogan’s stance, however, is December 2013, when financial police arrested 47 members of an alleged corruption ring, including businessmen, state officials and the sons of several AK party cabinet ministers. Recordings of embarrassing personal calls, including some apparently with Mr Erdogan—who has denied their authenticity—soon appeared on the internet. They painted a picture of nepotism and influence-peddling, much of it involving lucrative construction contracts handed to party favourites. Dozens of officials were forced to resign.

The motive for the arrests and the leaks was not hard to find. For several years trouble had been brewing between the AK party and Hizmet, a shadowy religious-nationalist movement founded by Fethullah Gulen. a charismatic prayer leader who preaches a mild, Sufism-inspired and public-service-oriented form of Islam. Mr Gulen has lived in self-imposed exile in America since the 1990s, but his influence in Turkey, created over decades, has remained strong.

In the AK party’s early years Hizmet was a powerful ally. Its media outlets boosted the Islamist cause, and graduates from its universities provided a useful pool of white-collar talent for the AK party. Not unlike the Freemasons, the movement had followers throughout Turkey’s government, but particularly in the police and the judiciary. After the AK party’s election victory in 2002 they were seen as key to the dismantling of Turkey’s “deep state”, and particularly to the show trials of military officers. The leaking of tapes that damaged the reputation of secular rivals to the AK party was also linked to Hizmet.

The Gulenists may have been prompted to air the AK party’s dirty laundry by Mr Erdogan’s decision in late 2013 to close hundreds of Gulen-affiliated schools. Whatever the reason, the AK party’s response has been ferocious, amounting to a witch hunt against Hizmet supporters and sympathisers. Since January 2014 some 6,000 police officers have been transferred or fired on suspicion of ties to the group. Waves of arrests have targeted journalists, lawyers and academics, among others.

The enemy within

In December 2014 Mr Gulen, who is 74, was officially declared the head of a terrorist organisation bent on establishing a “parallel state”. That has allowed prosecutors to charge alleged associates, including newspaper editors, with terrorism offences. The government also reversed earlier convictions that had been secured with the Gulenists’ help. Nearly all military officers who had been subjected to show trials were released.

Some of the charges of attempted Gulenist infiltration may well be justified. Yet most Turks other than core supporters of the AK also feel that the allegations of corruption against the ruling party cannot be dismissed out of hand. To many, Mr Erdogan’s furious persecution of this “enemy within” is a way of deflecting attention from the AK party’s own plans for capturing the state. “They are not just crushing what exists,” says Mr Onderoglu of Reporters Without Borders. “They are building new media, a new civil society and a new deep state.”