On a crackly Skype line from Ankara, Turkey, the story I heard was both new and strangely familiar. I was speaking to an academic, a man with a belief in freedom and free markets, and he was telling me about the arrests, detentions and firings of his colleagues. Sahin Alpay, a 72-year-old liberal journalist with wide European contacts. Orhan Kemal Cengiz, a human rights activist and journalist. Ihsan Dagi, a professor of international relations and theorist of democracy. Lale Kemal, a journalist who writes about the military and security. And there were others.

None of them, he told me, had supported the failed coup in July. None of them were “Gulenists,” followers of the reclusive Islamic cleric, Fethullah Gulen, a Pennsylvania resident whom President Recep Tayyip Erdogan blames for the coup attempt. Some of them had written in the past for a newspaper, now shut down, that Gulen supporters had owned; others had not. What linked them was something different: All of them were “democrats” or “liberals,” in Turkish terms — a category of people whom the Turkish president finds threatening. Liberals have questioned his attacks on the media and judiciary. Liberals have investigated him for corruption. Liberals want to reduce the power of the state that he directs.

The identification and elimination of whole classes of “enemies” is an old totalitarian practice; so is the arrest of people not for what they have done, but for who they are. It’s not a sign of strength. On the contrary, it’s what dictators do when they are afraid or paranoid, when they feel isolated, when they worry that the sycophants around them might be secretly plotting their overthrow. They use violence because they fear that they are losing support.

Dictators who fear their enemies also look for allies. But they don’t want allies who will criticize what they are doing, either out loud or by example. And so, in the wake of the failed coup and the successful crackdown, Erdogan naturally sought out the company of Vladimir Putin, the Russian president. In St. Petersburg this week, the settings at a luncheon for the two men included porcelain plates decorated with their portraits.

At least until now, Putin’s model of suppression has differed from Erdogan’s strategy. Instead of mass arrests, he has used targeted violence. To intimidate journalists, he ensures that one is occasionally murdered; to scare oligarchs, he locked up one of them for a decade. He controls the economy through a system of cronyism and kickbacks on a breathtaking scale.

But like Erdogan, Putin needs company. Both men share a paranoid fear of the enemies they can’t see. Both men know that a large portion of their population dislikes them. Both men know that the academics and intellectuals arrested in Ankara or under siege in Moscow will always oppose them, even if they are forcibly silenced. Both men know that the biggest threats to their personal power are the ideas and causes that those people represent: not merely democracy but also rule of law, judicial independence, media freedom, human rights.

Both were also nearly at war with one another just a few months ago. In November, the Turks shot down a Russian jet that had entered their airspace; the two countries are on diametrically opposite sides of the Syrian conflict. Many NATO leaders feared Turkey, a NATO member for decades, would drag them into an open war.

Geostrategic, military and even historical calculations should make Turkey and Russia antagonists. But their meeting illustrates something that many Western politicians and “realist” thinkers find difficult to understand: that ideas and ideology sooner or later trump “interests.” If Turkey were still a democracy, Erdogan would be looking to his Western allies to help him push back against Russia. But contact with the West also means contact with Western ideas. Dependence on the West means dependence on states that believe in the legal norms which Erdogan wants to repress, states that might support the people Erdogan wants to lock up.

We can tell ourselves all we want that, in this cynical world, the United States and Europe should pursue realpolitik goals and financial interests. We can argue that the nature of the regimes we support shouldn’t matter, that cold-eyed calculation should determine our foreign policy. But when it really matters, dictators choose other dictators over everything else. Democrats should take note.

Read more from Anne Applebaum’s archive, follow her on Twitter or subscribe to her updates on Facebook.