AFTER a year of terrorist attacks and a violent coup attempt, Istanbul residents are getting used to the sound of explosions. When blasts rang out near the city’s best-known nightclub just after 1am on January 1st, some thought they were new-year pyrotechnics. Yet the skies above them were empty. A massacre was unfolding below. By the time it was over at least 39 people, mostly foreigners, were dead, and dozens more wounded. Autopsies suggested that many had been shot at close range. Some saved themselves by leaping into the Bosporus. As The Economist went to press the attacker, a suspected follower of Islamic State (IS), had not been caught.

IS has carried out at least eight big attacks in Turkey, including the deadliest in the country’s history, a suicide-bombing that killed more than 100 people in October 2015. The nightclub attack is the first it has undisputedly claimed. In an online statement the group praised the shooting as an attack on an “apostate” celebration and revenge for a Turkish offensive against it in Syria. Turkey’s army cleared IS from strongholds overlooking the border in early September, and fighting continues near al-Bab, a town north-east of Aleppo.

Under pressure in Syria, IS has struck back by destabilising Turkey. The group’s earliest attacks in 2015 helped to reignite a war between Kurdish militants and Turkey’s armed forces. A second wave scared away tourists and fanned resentment of the 2.8m Syrian refugees living in Turkey. The latest, which hit a venue where celebrities dance and drink alongside foreigners and the monied elite, threatens to inflame tensions between Islamists and secular Turks, many of whom blame the pro-Islamist government for the spread of extremism. “Islamic State reads Turkish society very well and it knows to strike at the key pressure points,” says Hilmi Demir, an expert on Muslim sects and radicalisation.

Those pressure points are multiplying. Instead of healing his divided country after the coup in July, Turkey’s president, Recep Tayyip Erdogan, cracked down on his opponents, including Kurdish activists, leftists and secularists. Official discourse is increasingly conservative. In December the country’s religious-affairs directorate, the Diyanet, joined Islamist groups in proclaiming that new-year festivities were “alien” to Turkish values. Meanwhile, a group of young ultranationalists staged a protest at which they pretended to hold Santa Claus—that unwelcome Western intruder—at gunpoint.

Losing the plot

Many Turkish conservatives refuse to admit that innocents, including Muslims, are being murdered by a group acting in the name of Islam. They prefer conspiracy theories. A pro-government newspaper claimed the attack on New Year’s Day was the work of a “mastermind”, shorthand for an alliance of Western powers. An MP from the governing party blamed—who else?—the CIA.

The shooting also raised questions of accountability. More than 400 lives have been lost in big terrorist attacks since the summer of 2015, yet not one minister has resigned. Just over a week before the nightclub attack, Russia’s ambassador was fatally shot by an off-duty Turkish policeman. The government says it foiled 339 attacks last year. But it has also used the war on terrorism as an excuse to silence critics. In December authorities detained a Wall Street Journal reporter for three nights, allegedly for retweeting an image from an IS murder video. Days later they arrested an investigative reporter, Ahmet Sik, on farcical terrorism charges. Since the coup, more than 100 journalists have been locked up.

Largely because of the state’s control over religious debate, support for IS among Turks is minimal. Yet the group is determined to pit Turkey’s traditionally tolerant brand of Islam against an emboldened fundamentalist fringe. IS wants to galvanise those Islamists who condemn secular ways of life, says Rusen Cakir, a journalist. “They want to transform Turkey into a battlefield,” he says.

The New Year’s Day attack could serve as a wake-up call. The ruling Justice and Development party is realising that polarisation can win elections “but that it makes the country ungovernable,” says Ozgur Hisarcikli, head of the Ankara office of the German Marshall Fund, a think-tank. The Diyanet has declared that an attack on a nightclub is as reprehensible as an attack on a mosque. Mr Erdogan himself has warned against allowing the fault lines in Turkish society to widen, which is exactly what IS wants. Alas, Mr Erdogan’s populist authoritarianism, jingoism and repression are only wedging them further apart.