On Friday, militants from the Kurdistan Workers' Party (PKK) went into a cafe in the Turkish city of Diyarbakir and opened fire on a table of police officers, wounding three and killing a nearby waiter. This wasn't random: It's part of an upswing in fighting between Turkey and the Kurdish group since July that's already killed hundreds. The Turkish government has imposed a crushing set of restrictions on the town of Cizre, where, according to the BBC, "residents in the mainly Kurdish town say they have been unable to buy food or medical supplies."

This is some of the worst violence the country has seen since the 1990s. On the surface, the conflict is the latest cycle of violence between two longtime enemies that has gone on for decades. But it's also about the impact the Syrian war is having on Turkish society, as well as some pretty nasty changes in Turkish domestic politics.

The immediate problem: tit-for-tat fighting between the PKK and Turkey

The PKK is a Kurdish nationalist group with Marxist roots, founded in 1978, that has long fought the Turkish government, which considers it a terrorist group. It seeks autonomy for Turkey's ethnic Kurdish minority, who are concentrated in the country's southeast. The fighting, over the decades, has killed about 40,000 people, with violence peaking in the 1990s.

There had been some signs of progress: Turkey's leader since 2003, now-President Recep Tayyip Erdogan, opened up negotiations with the PKK in 2012, and eased some (though far from of all) of the country's infamous restrictions on Kurds, including a ban on private schools teaching the Kurdish language and even a ban on certain Kurdish letters. A ceasefire took hold in 2013, and it looked like it might turn into an actual peace treaty.

Recent events have dashed those hopes. On July 22, the PKK killed two Turkish police officers in the city of Urfa. According to Aaron Stein, a nonresident fellow at the Atlantic Council's Rafik Hariri Center for the Middle East, the killing was in retaliation for an ISIS suicide bombing on the Turkish border on July 20. That might seem odd, since Turkey is bombing ISIS positions in Syria. But Turkish Kurds believe the Turkish government secretly supports ISIS (more on this below).

At this point, "the state had a choice," Stein told me. "They could either go back to the peace process and choose not escalate, or escalate. They chose to escalate." The Turkish government bombed PKK positions, including some in Iraq, and sent police and troops into some heavily Kurdish cities.

"The goal of the airstrikes in Iraqi Kurdistan and southeastern Turkey is to force the PKK to withdraw and disarm," Stein says. "The goal of the operations in cities is to clear them [of PKK presence] and then hold them."

The PKK has responded with some deadlier tactics than it has used in the past, raising casualties above even the previous bouts of fighting in 2009 and 2012.

"One of the reasons you're having more violence and more casualties on the Turkish side is that they've adopted IEDs," Stein explains. "The big attacks are roads attacks on military convoys; 16 guys killed and then 14 the day after. So you've had a huge spike in casualties in the past week."

Either side could still choose to escalate further. Turkey could, for example, move thousands more troops into Kurdish-dominated cities in a more determined campaign to root out the PKK. The current fighting has not been all-out war, in other words, but rather tit-for-tat attacks, though that could potentially spiral out of control.

"Even if, at the beginning, both Erdogan and the PKK may have seen this surge in violence as episodic and manageable, there is a real risk of it being derailed and escalating in an uncontrolled and unmanageable way," Sinan Ülgen, a visiting scholar at the Carnegie Endowment for International Peace, says.

"We are really approaching that sort of scenario, where none of the players will actually be able to control a new cycle of violence."

How the wars in Syria and Iraq bled into Turkey

There's a really important regional backdrop to this story: the war in Syria, and, to a lesser extent, the conflict in Iraq. The nature of Turkey's role in these wars has made the PKK more popular among Kurds in Turkey, intensified their anger at Turkey's government, and left that government frightened of the PKK's growing influence.

When the Syrian civil war really heated up in 2012, the Kurdish minority in the country's north essentially seceded. They created what amounts to a de facto autonomous Kurdish state, called Rojava, and set up a military force — the People's Protection Units (PYD) — to defend the area.

That "changed the game," according to Stein, "for Turkey and for Kurds." From Turkey's point of view, Rojava was a threat; the PYD (in Syria) has very strong links to the PKK (in Turkey), and so could potentially furnish them with new bases. Moreover, de facto Kurdish independence in Syria threatened to strengthen Kurdish nationalist sentiment in Turkey.

"What happens in Syria doesn't stay in Syria, because the border is open," Soner Cagaptay, the director of the Turkish Research Program at the Washington Institute for Near East Policy, explained. "The Turkish Kurds are really excited — especially nationalist, pro-PKK Kurds — by the successes of the PKK's sister organization in Syria."

ISIS brought these tensions to the fore. Beginning in 2013, ISIS began assaulting Syrian Kurdish territory. In the summer of 2014, it invaded Iraqi Kurdistan, and threatened to exterminate the ethnically Kurdish Yazidi minority in Sinjar province. It also laid siege to Kobane, a Syrian Kurdish town on the Turkish border. The Turkish government refused to help Kobane in any meaningful way, infuriating the Kurds.

"The Sinjar situation really centered awareness that ISIS was trying to exterminate Kurds, followed quickly by Kobane," Stein says. "It built on the narrative, deeply felt ... that the AKP [Erdogan's political party in Turkey] supports ISIS. That the AKP supports our mortal enemy that wants to exterminate us, and only we Kurds can protect ourselves. And the only Kurds that are doing any good job of it are the PKK, so we need to support them."

It got to a point, in October 2014, where the PKK was threatening open war with the Turkish government if Turkey didn't help lift the siege on Kobane.

This is how the July ISIS suicide bombing along the Turkish border was able to kick off the current round of fighting. Many Kurds see Turkey as tacitly supporting ISIS, or at the very least not sufficiently fighting it, and believe this is in part aimed at them. Trust between the sides, already low, is ebbing — and, as such, the peace process is collapsing and violence is rising.

Both sides have political incentives to escalate the conflict — for now

Politics in Turkey threaten to make the situation worse. Turkey has new elections on November 1, following the shock June elections that denied Erdogan's party, the AKP, a parliamentary majority for the first time since 2003.

Erdogan is looking to consolidate the Turkish nationalist vote to improve on his party's showing — which gives him an incentive to step up the war on the PKK (the Kurdish group in Turkey), something nationalists want.

"One way to get [to a majority], in the mind of the president, is an increasingly nationalist hue to his party," Cagaptay says. "Battling the PKK ... feeds into that image of the AKP as the Turkish nationalist party."

And the PKK, for its part, can also benefit politically from the fighting, as conflict with the Turkish government strengthens pro-PKK nationalism, already rising due to Syrian Kurds' successes against ISIS.

"One of the reasons the peace process began to falter is that on the AKP side, Erdogan, beginning in March, began to speak out against the Kurdish peace process," Stein explains.

"The Kurdish political movement became very strident in their criticisms of Erdogan," Stein goes on, "and that's continued. So when the state faced the choice in late July about whether to escalate or to continue with the peace process, they chose to escalate. In that sense, certainly, domestic politics are playing a key role in what's going on — on both the Kurdish side and the PKK side."

That doesn't mean escalation will necessarily continue, though. If the elections are contributing to Erdogan's heavy-handedness, than he may be willing to back off after the November vote.

"If this cycle of violence is essentially a byproduct of Turkey's electoral cycle," Ülgen says, "at the end of the electoral cycle ... there can be hope for Turkey to revitalize the peace process, and therefore end the cycle of violence."

Even if that's correct, November is still a ways away, and in the meantime the violence is continuing.