In Turkey’s southeast, many towns are under curfew. Erdogan is waging a relentless campaign against the Kurds in the shadow of the Syrian war. Kurdish territorial inroads and self-government in northern Syria have awoken the darkest specter in the Turkish psyche: a border-straddling Kurdistan.

ISIS, by comparison, has been an object of ambivalence. Erdogan has played a double game.

For a long time he allowed ISIS recruits to move across Turkey and over the border to the Islamic State’s Syrian stronghold of Raqqa. Given a choice between the terrorists of the Islamic State in northern Syria and what, for him, are the Syrian-Kurdish terrorists of the P.K.K.-affiliated Democratic Union Party, or P.Y.D (and its associated militia, the Y.P.G.), the Turkish president has no doubt who is more menacing.

ISIS has had anti-Kurdish uses for Erdogan. By contrast, the Kurdish enclave in northern Syria, known as Rojava, is only trouble from a Turkish perspective. That the Y.P.G. has, in effect, been America’s most effective ground force against ISIS complicates Erdogan’s position. Turkey is a NATO ally opposed to America’s anti-ISIS Syrian-Kurdish alliance.

Welcome to the Middle East. I hope everything is clear in this Kurdish alphabet soup (I have not even mentioned Turkey’s Kurdish-dominated Peoples’ Democratic Party, or H.D.P., out of deference to you, dear reader.) If all is fog, please at least retain the following:

Erdogan has found himself in a terrible neighborhood, his country destabilized by more than five years of war in Syria and the millions of refugees pouring across the border. He has been frustrated, with reason, by President Obama’s unwillingness to back with a coherent policy his statement in 2011 that President Bashar al-Assad of Syria must “step aside.” But, in the end, Turkey’s descent into violence is of Erdogan’s own creation.

Prickly and erratic, he has perceived enemies everywhere — in the press (whose freedom he has stifled), among former business allies, in the secular Turkey that resists his increasingly unbridled attempts to advance an Islamist agenda. Turning his back on years of attempted reconciliation with the Kurds, he has adopted an uncompromising brutality. Seeing his power threatened, he was prepared to countenance violence to instill an atmosphere of fear in the run up to last year’s November election, so that he could emerge as strongman-savior.