Long criticised by its allies for taking too soft a line against jihadists, Turkey is taking firmer action against the Islamic State (IS) on the border with Syria after being shaken by attacks on its soil and the Paris assaults.
Ankara is sealing its border to the jihadists who moved to and fro across the frontier during much of the four-year civil war in Syria and stepping up raids against IS suspects.
It says it is also moving with the United States in a joint air operation backed by rebel forces on the ground to wrest 98 kilometres (61 miles) of the Syrian border in the hands of jihadists.
Until now, Turkey's NATO allies had been alarmed Ankara turned too much of a blind eye to extremist Islamist forces in Syria in the hope they could help in its aim of ousting President Bashar al-Assad.
Western sources lamented that jihadists would arrive in Istanbul by air from Europe, go by road to the southern cities of Sanliurfa or Gaziantep and then cross the border into Syria.
"The Turkish authorities were perfectly aware of this traffic," said a western diplomat.
"They let it happen, making the bet that it would hasten the fall of their arch enemy Assad."
Turkish soldiers pictured in June detaining men who had come across the border from Syria and suspected jihadists.
Turkey has vehemently rejected accusations of failing to properly police the 911 kilometre (566 mile) border, saying its sheer length makes it impossible to block off entirely.
Ankara has also called for better intelligence sharing from its allies -- a complaint also echoed by its western partners.
Yet there has been a shift as it became clear that IS was a threat to Turkish territory as anywhere else.
Aside from the attacks in Paris, on a Shiite suburb of Beirut and a Russian aircraft above Egypt, there have been three deadly attacks blamed on IS inside Turkey the last months.
On June 5, four people were killed in an attack on a rally of the main pro-Kurdish party in Diyarbakir while on July 20, 33 people were killed in a suicide bombing on activists in Suruc on the Syrian border.
And in the worst attack in modern Turkey's history, 103 people were killed on October 10 when two suicide bombers ripped through a crowd of peace activists in the capital Ankara.
The military now announces almost daily that suspected militants have been detained at airports or the border.
Meanwhile, there has also been an increase in raids against suspected jihadists -- particularly ahead of Turkey's hosting of the G20 earlier this month.
Turkey is also putting up a concrete wall along the border with Syria in its southern Hatay province, a third of which has now been built.
"That things have improved is indisputable," said a western diplomat. "But it's not enough."
'Real threat to Turkey'
Turkish officials dispute the notion that Ankara has suddenly woken up to the IS threat, noting the group has been listed as a terror organisation by Turkey since its emergence.
Relatives mourn near the grave of a victim of the twin bombings in Ankara, during the funeral in Istanbul on October 12, 2015.
Ankara has also put 26,600 suspected militants from across the world on an entry ban list, officials say.
"Turkish authorities have been doing more to clamp down on ISIS activities both inside Turkey as well as across the Turkish border since the start of 2015," said Naz Masraff, Europe director of the New York-based political risk analysis firm Eurasia Group.
There is "a growing awareness that ISIS posed a real threat to Turkey's own security," she added, using a variant name for IS.
But observers warn this will not be enough, given the likely existence of IS sleeper cells in Turkey and the risk of jihadists mixing into genuine refugees from Syria.
"Hundreds of Syrians cross the border daily so it isn't difficult for members of Daesh to infiltrate them," said Taym Ramadan of the NGO Raqa Is Being Slaughtered Silently, using the Arabic acronym for IS.
"Daesh is able to move its members not only between Syria and the whole world, not just Turkey."