Turkey’s megalomaniacal president, Recep Tayyip Erdogan, has turned his once-promising developing country into a gulag state. The mechanism by which the increasingly one-party government has accomplished this Stalinization of the country is the tagging of millions of Turkish citizens as terrorists. The charge is unrelated to any actual act of terrorism. Erdogan has made them the political equivalent of ritually impure, branded as outcasts because they associated with other outcasts. Erdogan’s “anti-terror” net has now swept up the German government of Chancellor Angela Merkel, the US Pentagon, and even Amnesty International.

Erdogan focuses in his speeches on two bêtes noires, the neo-fundamentalist Muslim Gulen movement and the Kurdistan Workers’ Party (PKK). He has legitimate grievances against leaders of both groups, but he has gone much further, tarring ordinary Gulenists and Kurds, as well as anyone who stands up for their civil rights, as terrorists. Moreover, Erdogan himself allied with the Gulen organization in the early 2000s, forming a united front of modernist, pro-Islam groups to challenge the top-down secularism of Turkey’s old 20th-century elite. If the Gulenists are really so universally wicked, surely Erdogan himself should resign over one of the great instances of poor political judgment in our new century.

In late July, UK Foreign Secretary Boris Johnson protested to Turkey over its arrest of the chair and the director of Amnesty International Turkey, Idil Eser and Taner Kiliç, respectively. Human-rights activism, in other words, is in Erdogan’s Turkey a form of material support for terrorism.

Turkey has given Germany dossiers on 4,500 Turks in the latter country it wants arrested, and is angry that the Merkel government does not agree that people may be made taboo by fiat despite having not actually committed a crime. Nor will the German police stop Turkish Kurds from rallying to protest Erdogan’s scorched-earth tactics in the villages of eastern Anatolia. Erdogan lashed out at German officials again this week, accusing them of abetting terrorism. Many German parliamentarians are convinced that Turkey’s prospects for ever joining the European Union, slim to begin with, have been ended by Erdogan’s authoritarianism. They are increasingly unhappy that it is a full member of NATO.

Ankara certainly is not acting very much like a NATO ally with regard to US efforts against ISIL (the Islamic State, ISIS, or Daesh) in Syria. Because the Pentagon has allied with left-wing Syrian Kurds, whom Erdogan sees as linked to the PKK, it has been thunderously denounced by Turkish government officials as supporting terrorism. Turkey itself has offered little help to the United States in rolling up ISIL.

Because the charge of supporting terrorism only requires standing up for the basic human rights of outcast groups, secular intellectuals inside Turkey have also been prosecuted by Erdogan’s allies. The opposition newspaper Cumhuriyet (The Republic) has been a thorn in Erdogan’s side for reporting on rights abuses, and therefore 19 of its journalists were charged with abetting terrorism last fall. All but four have now been acquitted by the courts. Last month, even faculty at the staunchly secularist Bogazici (Bosphorus) University in Istanbul were arrested on implausible charges of Gulenist sympathies. Their actual infraction may have been to use the local smartphone security app, ByLock, which Turkish cyber-police associate with plotting terrorism. Internet privacy applications have been banned by the increasingly Orwellian Turkish state.

Erdogan saw the attempted coup of July 15, 2016, as a conspiracy centrally directed by Fethullah Gulen, the leader of the secretive Hizmet organization. Gulen was granted asylum in the United States in the late 1990s, when mixing religion and politics had been criminalized by the secularists then in control of Turkey. Because Erdogan and the Gulenists were for so long political allies, and because Turkey still has something of a spoils system, the Gulenists appear to have seeded members throughout the government, in the police, the judiciary, the universities, and the army.

Beginning in 2013, Gulenist moles in the government began attempting to destroy Erdogan politically by leaking damning conversations they managed to record, one of him directing his son to get large amounts of cash out of their home in advance of a corruption probe. Erdogan told his constituency that the leaks were fake news, and suffered no fall in popularity. He clearly began fearing that his Gulenist partners, having jointly come to power with him, were plotting to sideline his Justice and Development Party (AKP) and take over the government. From his point of view, the attempted coup was the culmination of this plot.

Erdogan’s hold on power had been challenged by another political grouping, this one center-left, from the 2015 elections. The pro-Kurdish People’s Democratic Party (HDP) put up an unexpectedly good showing in June of that year, gaining 13 percent of the seats in Parliament. Its leaders campaigned on multiculturalism, women’s and gay rights, and minority rights. The some 20 percent of the Turkish population that is of Kurdish heritage is politically diverse. Some are conservative Muslims and had voted for Erdogan. Others are on the left. The HDP appears to have attracted votes from even conservative Kurds, much reducing the percentage of seats Erdogan’s AKP gained, to 40 percent.

Since Erdogan had hoped his AKP would gain an absolute majority in Parliament to amend the Constitution and move to an imperial presidency, the rise of the HDP proved extremely inconvenient. He was handed a gift in the summer of 2015, however, by the radical Kurdish guerrilla movement, the PKK, which may also have been alarmed at the rise of a moderate party that appealed to Kurds. The PKK went on a rampage, attacking Turkish soldiers and police.

Erdogan responded by breaking off peace talks with the PKK and deploying the military against Kurdish populations suspected of supporting them. When snap elections were called for November 1, 2015, because of a hung parliament, Erdogan’s AKP recovered enough ground, with 50 percent of seats, to form a government on its own, and the HDP was reduced to 10 percent of seats.

Erdogan then made simply being pro-Kurdish a crime, and gradually moved on HDP members, even on parliamentarians, trumping up cases against them on grounds of supporting the PKK guerrilla organization. The HDP had consistently stood against guerrilla violence of that sort; nevertheless, their MPs have gradually been stripped of their parliamentary seats and their leaders jailed. With each HDP MP removed, Erdogan’s majority in Parliament is strengthened.

After the failed coup, Erdogan went on an Egypt-style binge of firings and arrests, jailing some 50,000 people and firing 150,000 government employees on grounds that they were linked to the Gulenists. Universities founded by the Gulenists were abruptly shuttered, leaving thousands of students without a degree. While prosecuting the coup plotters is legitimate, obviously 200,000 Turks did not conspire to overthrow the government last summer. And while the Gulenists may or may not be a cult, as Erdogan now alleges, if any individual among them has not committed a crime, it is a violation of their rights to deprive them of employment or imprison them for thought crimes. What Erdogan has done is the equivalent of the Republican Party in the United States, having gained power by allying with evangelicals, abruptly declaring all Southern Baptists to be terrorists.

Erdogan came to power through democratic means, but he does not believe in an ongoing civil society–based democracy. He thinks of the government as an elective dictatorship, in which voters are offered a choice, say, every few years, but after which they should sit down and shut up. He has connived at maintaining an electoral majority comprising the Muslim middle classes in Anatolia and some urban right-wing secular Turkish nationalists. Erdogan’s government had been moving in the direction of a persecuting state for years before the bungled 2016 coup gave him the perfect pretext to jail tens of thousands of critics, close down newspapers and universities, and intimidate the country into silence. Turkey has become an object lesson for anyone in democratic societies. When you hear a government official shouting the phrase “war on terror,” be afraid. Be very afraid.