As ISIS wreaked havoc on parts of Iraq and Syria, Turkey, their neighbor to the north, sat on its hands.
After all, the Turkish government opposed the Syrian regime of Bashar al-Assad. And ISIS was fighting that regime, too.
Also, last fall the Turkish government negotiated the release of 49 hostages captured by ISIS from the Turkish consulate in Mosul -- including the consul-general himself.
So what did ISIS get in return for releasing the hostages? Could Turkey have made a non-aggression pledge?
No details have been divulged.
Now, suddenly, Turkey has reversed itself. It is allowing American bombers to use the Incirlik Airbase in southern Turkey to hit ISIS targets in Syria. And Turkey itself has launched air raids on ISIS targets in Syria -- and on Kurkish camps in northern Iraq.
All of which raises several questions:
Q: Why has Turkey shifted its stance on ISIS?
A: Turkey has been under intense international pressure for some time to take action against ISIS, a global threat that is active right in Turkey's backyard.
Now, on July 20 a suspected ISIS suicide bomber killed 32 people in the Turkish town of Suruç, near the Syrian border -- not the kind of thing any national leader can accept.
And two days later, Turkish President Recep Tayyip Erdogan found himself on the phone with U.S. President Barack Obama.
"It looks like they clearly made a deal," said Esra Ozyurek, chair of Contemporary Turkish Studies at the London School of Economics.
The two leaders had barely hung up the phone when the U.S. began using the Turkish air base. And Turkey began hitting ISIS at once.
So what did Turkey get in return for the shift? As with the hostage negotiations with ISIS last fall, we just don't know.
Q: Why wasn't Turkey doing much to fight ISIS before?
A significant number of ISIS members are reported to be Turkish, and they may have support back home in Turkey. Politicians notice things like that.
And ISIS is fighting the al-Assad regime. The Turkish government, while saying it opposed terrorism at every turn, appeared to be heeding the old adage, "The enemy of my enemy is my friend."
Also, as noted, a deal of some sort was reached last fall between ISIS and Turkish officials. ISIS is not the kind of group to release 49 captives while getting nothing in return.
Q. Why has this also affected talks with Turkey's Kurds? Is the peace process dead?
Some of that may be coincidence.
The government and Kurdish representatives came close to achieving a deal last year. That would have been a historic moment, ending a conflict that has killed 45,000 people since 1984, when the Kurdistan Workers Party, or PKK, launched a violent drive for independence.
But now the Turkish government has hit PKK camps in Iraq and arrested numerous PKK members inside Turkey. For its part, the PKK has said the ceasefire with the government has "lost its meaning."
Ozyurek, of the London School of Economics, views the assault on the Kurds as the result of a failed electoral strategy.
Erdogan and his AK Party wanted a two-thirds majority in Parliament so they could amend the country's constitution, strengthening the powers of the President -- namely Erdogan himself.
To achieve that, the AK Party needed to hold the Kurdish-oriented People's Democratic Party, or HDP, under 10% of the vote nationwide. That would mean it would get zero seats in Parliament.
The strategy failed. The AK Party, despite Erdogan's efforts to make nice with an agreement, did poorly in Kurdish areas in southeastern Turkey. The HDP won 13.1% of the vote nationally and 80 seats in Parliament.
And the AK Party did not even win the simple majority that would have allowed it to govern on its own, never mind two-thirds.
So, in Ozyurek's estimation, Erdogan wants to hit ISIS, showing that the country is at war and needs strong leadership, not a coalition government.
And he no longer sees any reason to placate the Kurds, Ozyurek said, so he's using ISIS as a cover to round up Kurdish activists.
The peace deal that was so close ? Gone. Violence may resume.
"I think we can say that the peace process is over," Ozyurek said.
Does Turkey's assault on ISIS heighten the terrorist threat to its tourist and commercial areas?<