Analysts say the fight in Azaz has much more behind it than just a dispute over a German doctor. Tensions between the FSA and ISIS had peaked after Kamal Hamami, a member of the FSA’s top executive body, was shot dead by the ISIS “emir” in the town of Idlib in July. The sides have viewed each other as enemies ever since.

The result, according to press reports from the region, was that Azaz came under ISIS control and this has forced Turkey to close the nearby Oncupinar border crossing with Syria indefinitely. Whatever the real reason behind it may be, this incident shows just how volatile the situation is among the different groups fighting the Bashar al-Assad regime.

The latest clashes between the Free Syrian Army (FSA) and the group that calls itself the Islamic State of Iraq and the Levant, or ISIS for short, reportedly broke out on Sept. 18 in the town of Azaz, just across the border from Kilis in Turkey. These are said to have started because the FSA refused to hand over a German doctor to the radical Islamic group for questioning over pictures he took of wounded combatants from the group.

Not surprisingly Turkish commentators have already started referring to certain regions along the highly porous border with Syria, which is nearly 900 kilometers [560 miles] long, as “Turkey’s North-West Frontier Province,” a reference to the lawless region of Pakistan that is a hotbed of Islamic terrorism.

Turkey’s Syria nightmare keeps going from bad to worse. Ankara is already smarting that Syrian Kurds with close links to the Kurdistan Workers Party (PKK) have taken control over some areas adjoining the Turkish border. It has to contend with the possibility that an al-Qaeda-affiliated group may entrench itself in another swath of land adjoining Turkey.

This latest outbreak of violence clearly shows that even if Syrian President Assad is ousted, the fighting in Syria will most likely continue, except that this time it will be between moderate secular elements and radicals wanting to turn Syria into a strict Islamic republic.

This latest development is also taking place against the backdrop of a diplomatic process initiated by Russia and the United States for Syria’s chemical weapons, which not only elevates Assad’s status internationally as an official interlocutor, but also carries the potential of shifting the emphasis in Syria from the military to the diplomatic track.

The government of Prime Minister Recep Tayyip Erdogan, however, had based all its plans on what is now clearly seen to be the mistaken assumption that Assad would be ousted militarily sooner or later. This was probably why it gave a lukewarm endorsement for the plan worked out by Russia and the United States. Ankara is bracing for the possibility of a negotiated settlement in Syria that leaves the Assad regime intact, at least until the situation is stabilized enough for a more democratic environment to emerge.

That aside, however, and whatever animosity Erdogan may feel for Assad — and he certainly makes no secret of it — a prospect far more worrying has emerged for Turkey than Assad remaining a political actor in Syria: a divided Syria. The Erdogan government was already faced with a situation where various elements that fought together against Assad were engaging in bitter and bloody fighting among themselves to gain control over parts of the country.

It is clear that even if the regime can bring relative stability to those areas under its control, areas not under its control, especially in regions along the long border with Turkey, will continue to see violent confrontations with civilians caught in the cross fire. This will inevitably result in a new wave of refugees surging into Turkey, adding to Ankara’s growing Syrian headache.

Meanwhile, clashes in northern Syria between Kurds, operating under the banner of the Democratic Union Party (PYD), and the al-Qaeda-affiliated Jabhat al-Nusra, have already resulted in a series of faits accomplis along Turkey’s border that are highly displeasing to Ankara, but over which Turkey has hardly any influence.

Having once provided support to Jabhat al-Nusra, even promoting it in Western capitals as “the most effective force against Assad,” the Erdogan government is seeing this support coming home to roost. Aware that these groups have become a hindrance for Turkey, Foreign Minister Ahmet Davutoglu told the daily Radikal newspaper in July that they, including Jabhat al-Nusra, were doing the greatest damage to the revolution in Syria and therefore “betraying the Syrian people.”

The situation in Azaz — with a parallel situation reportedly developing in oil-rich Deir ez-Zor — not only makes the already complicated Syrian equation even more complicated for Ankara, but also puts Turkey’s border security at risk, given that radical Islamists appear to pass freely between the two countries.

Rojava, the Kurdish name for northern Syria where the PYD has more or less gained control, could under these circumstances end up being the only stable part of Syria for Turkey, thus replicating the situation of Northern Iraq. Although it is not happy that the PYD has gained ground in Rojava, the Erdogan government was nevertheless forced to reach out to the Kurdish group and hold talks with its leader, Salih Muslim, in Istanbul.

But Turkey’s ties with the PYD remain precariously dependent on how the Erdogan government’s stalled peace process with the PKK goes. Developments in Syria are also forcing the Erdogan government to come up with a new bill that will authorize any action by the Turkish military, including crossing the border if necessary, in the event of a threat to the country’s security from Syria.

The present authorization the government received from parliament last year, after the fighting in Syria started spilling over into Turkey, would expire at the end of this month.

Providing information about this, during a news conference in Ankara with visiting Romanian counterpart Victor Ponta this week, Erdogan said the new bill might include some changes. “The Foreign Ministry and the General Staff are now doing what is necessary. Then, we will make our assessment and submit it to the parliament,” Erdogan told reporters.

The initial parliamentary authorization was sought principally against Assad’s forces, and the downing of a Syrian government helicopter this week by the Turkish air force, after it strayed into Turkish airspace, was carried out according to the rules of engagement under this mandate.

It seems now, however, that any new authorization will have to factor in new risks which the Erdogan government did not think it would have to face, as it single- mindedly pushed for Assad to be toppled by military means, only to see all of its calculations fall by the wayside as events took their own course.

Semih Idiz is a contributing writer for Al-Monitor’s Turkey Pulse. A journalist who has been covering diplomacy and foreign policy issues for major Turkish newspapers for 30 years, his opinion pieces can be followed in the English-language Hurriyet Daily News. His articles have also been published in The Financial Times, The Times of London, Mediterranean Quarterly and Foreign Policy magazine.