Syrian President Bashar al-Assad's certain victory in an election next month, derided internationally as a charade, leaves Turkey facing a bitter truth - its assumption of his quick demise was a costly miscalculation.
With al-Qaida-linked armed groups controlling patches of territory across Turkey's southern border and a registered refugee influx set to top a million within months, Syria's three-year old war presents Ankara with an increasing financial burden and a growing security threat.
A gun battle in March when special forces raided the suspected Istanbul hide-out of an Islamist militant group active in Syria highlighted the potential threat to Turkey from the thousands of foreign jihadis who have been drawn into the conflict, a portion of them entering Syria over the Turkish border.
The torching of a building housing Syrian refugees in Ankara this month meanwhile pointed to anger at the growing social and economic costs of a humanitarian response which has already cost Turkey close to $3 billion.
With Assad facing no serious challenger in a June 3 election which his Western and Arab foes, as well as the Syrian opposition, have dismissed as a parody of democracy, such tensions are unlikely to dissipate any time soon.
“We may describe Turkish Syria policy as a mess. We've committed too much, we've talked too big,” said Osman Bahadir Dincer, Syria expert at the Turkish non-partisan thinktank USAK.
“At the very beginning Turkey underestimated the humanitarian problem. Turkey was not prepared and I think the same can be applied to border security.”
Prime Minister Tayyip Erdogan initially believed his stature in the Middle East and relationship with Assad might enable him to steer the Syrian leader away from conflict. In the early stages of Syria's uprising in 2011, Erdogan called on Assad to learn the lessons of the Arab Spring and step down.
Erdogan took Assad's failure to heed his advice as a personal affront, some of those close to him say, and within two years he was leading calls for international military intervention to end his former ally's rule.
“Turkey's Syria policy has shown the limits of its influence in the Middle East,” said Fadi Hakura, Turkey expert at the London-based think tank, Chatham House. “It is a clear sign to the U.S. and other partners that Turkey is an important player but not a rising star in the region.”
“Mocking the world”
After Syria announced in April that it would hold polls, Turkey was quick to dismiss any election as “null and void”. Foreign Minister Ahmet Davutoglu this month accused Damascus of “mocking the world” by organizing the vote.
Syria's authorities have not said how they will hold the vote in a country where six million people have been displaced and swaths of territory are outside government control.
Assad's forces have consolidated their grip around Damascus and central Syria, and hold the Alawite heartland provinces on the Mediterranean coast. Rebels control much of the north and east, but have been plagued by infighting.
Turkey is struggling to cope with the spillover.
“Even if you put a soldier on every meter, it's almost impossible to control if you don't control what's happening the other side of the border,” a senior Turkish government official said, asking not to be named in order to speak more freely.
“Turkey has always been a target, but this time we've got more of these radicals next to our border, that's an added threat. And they're supported by the Syrian regime,” he said.
Diplomats and security experts fear expertise developed by fighters inside Syria, such as the use of new types of explosives, could be used in attacks in Turkey or beyond.
Istanbul, where car bombs claimed by al-Qaida targeted the British consulate and local offices of HSBC just over a decade ago, and Turkey's Aegean and Mediterranean resorts, popular with European holiday-makers, are seen as potential soft targets.
Erdogan's critics say his government's scramble to support the rebels has allowed weapons and foreign fighters to flow to extremists, a charge it strongly rejects.
“Al-Qaida, Nusra are known by and supported by the (Turkish) government. Haven't you seen the trucks,” said 32-year old Nihat, a resident of Antakya, the main city in Turkey's Hatay border province, referring to convoys crossing the frontier.
Erdogan has said it is “out of the question” that such groups can take shelter in Turkey and has repeatedly stressed Turkey will continue to exclude them from its broader support for the moderate Syrian opposition.
Turkey has made a number of weapons seizures on the border.
The March raid on the suspected ISIL base in Istanbul followed the gunning down a week earlier of two members of the security forces in the southern province of Nigde by militants suspected of links to extremist groups inside Syria.
“We'll be seeing an increased threat of anti-Turkish and anti-Western terror for many years to come,” said one Ankara-based diplomat, saying the government was waking up only slowly to the need for a tougher approach on border security.
Throughout the conflict, polls have suggested the majority of Turks are against deeper Turkish involvement in Syria.
While its humanitarian efforts have been much praised by international partners, social tensions are beginning to surface in the face of ever spiraling refugee numbers, and the realization that many of them could be here to stay.
Turks living near the border express frustration that around three quarters of Syrian refugees are now living outside camps, competing with locals for jobs and housing. The torching of the Ankara building this month followed accusations that a Syrian man had beaten up a local. Riot police had to intervene.
Residents along the border reported a tripling in the price of staple foods like tomatoes, while rents had gone up by a factor of five, according to a USAK study from last November. In Istanbul, where land prices are already sharply on the rise, some poorer neighborhoods home to large numbers of Syrian migrants had doubled to $750 a month, it said.
The United Nations estimates there are 750,000 Syrian refugees in Turkey, although Turkish officials say the number is closer to 1 million, the vast majority of them living outside the more than a dozen camps established near the border.
“Registration is a mess. They have a pretty good estimate of how many people are in Turkey, but do they know exactly who they are and what they need? No,” said Jean Christophe Pegon, Turkey head of the European Commission Directorate-General for Humanitarian Aid and Civil Protection (ECHO).
Davutoglu said in an interview with Reuters earlier this year that Syria's worsening war posed a danger to all countries because of the “totalitarian” nature of Assad's rule and the influx of jihadists from around the world.
Turkey risks bearing the brunt while struggling to assert itself as a leader in coordinating a response.