Demonstrators hold pictures of victims as they chant slogans denouncing a suicide bombing in the Turkish border town of Suruc that killed 32 activists in Ankara on July 27. The Turkish government blamed Islamic State for the attack. (Adem Altan/AFP/Getty Images)

— For years, Turkey’s porous border with Syria provided a lifeline for the Islamic State, allowing the group to ferry weapons and fighters to a war zone where it was building its brutal “caliphate.”

But that is now changing.

Where jihadists once streamed over this frontier, high walls and police patrols now block the illicit flow. Turkish authorities began taking the tougher measures months ago, but they have intensified in recent days, as the government has pledged to join the U.S.-backed fight against the Islamic State.

The new agreement between the United States and Turkey would allow airstrikes on Islamic State targets from Turkey, which shares a 500-mile-long border with Syria, the jihadists’ home base. The deal also envisions the creation of a buffer zone just inside Syrian territory, with the expulsion of jihadists from their border strongholds. The “safe” area would host fighters from Syria’s more moderate opposition.

If implemented, the plan would enlist Turkey, which has the second-biggest military force in NATO, in the battle to weaken the jihadists’ caliphate. It was announced as Turkish security forces were also rounding up alleged sympathizers of the Islamic State in the country.

Turkey’s new role will “change the game in Syria, Iraq, and the region,” Turkish Prime Minister Ahmet Davutoglu told journalists in Istanbul on July 25, after his country’s air force hit Islamic State positions in Syria for the first time. Islamic State militants control wide swaths of territory in Iraq and Syria.

“There is no place [for the Islamic State] on Turkey’s borders,” Davutoglu said. “This is not the Turkey of just one week ago.”

Since Syria’s uprising broke out in 2011, Turkey has been accused of turning a blind eye as thousands of jihadists from Turkey, the Middle East, Europe and elsewhere slipped over its border to fight the regime of Bashar al-Assad. Many of them eventually went on to establish the Islamic State.

Turkish authorities were happy to support the opposition to Assad, who had become an enemy. Turkish officials complained that the West wasn’t doing enough to topple the Syrian president and protect Syrian civilians from the regime’s deadly airstrikes. More than 200,000 people have died in the conflict, according to the United Nations. The war has produced more than 4 million refugees — nearly half of whom have fled to Turkey.

But after suspected Islamic State fighters carried out a string of deadly operations on the border in recent weeks, Turkey was spurred into action against the jihadists, analysts say. One attack involved a suicide bombing that killed more than 30 civilian activists in the Turkish town of Suruc. In another assault, jihadists shot and killed a Turkish soldier.

“We always knew there would be a confrontation between Turkey and the Islamic State. It’s what we’ve all been warning about,” said Soner Cagaptay, director of the Turkish Research Program at the Washington Institute for Near East Policy.

Map: What a year of Islamic State terror looks like
Kurds pose another threat

For Turkish officials, the rise of the Islamic State is not the only worrisome development in their neighboring country. Syrian Kurds have battled the Islamic State near the border, pushing the extremists out of a swath of territory. That has alarmed Turkish authorities, who fear that ethnic Kurds in both Turkey and Syria could seek to create an autonomous state. Turkey has also started carrying out strikes on Turkish Kurdish rebel positions in northern Iraq, renewing a fight that has gone on for decades.

For months, U.S. and Turkish officials were negotiating a joint strategy to battle Islamic State militants from Turkish soil. Turkey has insisted that it will not send ground troops into Syria but will enforce a jihadist-free buffer zone with long-range artillery.

Under the accord, the United States will use Turkey’s Incirlik air base and other airfields to fly manned and unmanned aircraft for strikes on Islamic State targets. The proximity of the bases to Syrian territory means U.S. warplanes will be able to confirm and hit targets with much greater speed.

On a call with reporters this past week, a senior Obama administration official said that the United States was “very encouraged” by the accord with Turkey.

“We think it is potentially a very significant development in the ongoing campaign against Daesh,” the official said, using an Arabic acronym for the Islamic State.

The United States has carried out more than 5,000 strikes on the group in both Iraq and Syria since last August, according to the U.S. government. The official said the U.S.-led coalition would provide air cover for Syrian rebels on the border — but that Washington did not consider it a “no-fly zone” like the one enforced by the U.S. military in Iraq after the 1991 Gulf War.

While Turkey may have won U.S. praise for its new stance, the country also faces risks. It could become further enmeshed in Syria’s bloody conflict, putting Turkish civilians in the crosshairs of the Islamic State.

“Now it’s much more likely that [the Islamic State] will target Turkey,” Cagaptay said.

Watching the border in fear

In the Turkish town of Karkamis, the rising tensions are evident. The quiet town of cement brick homes is just a half-mile from Islamic State-held Jarabulus in Syria, on the other side of the border. The once-bustling official crossing here has been shuttered for months.

In recent days, residents say, they have heard mortar shells, drones and fighter jets flying overhead at night. Turkish soldiers have urged families living near the border to leave.

In the early mornings, residents say, they can see black-clad men — apparently jihadists — planting mines on the Syrian side of the border. Sometimes dogs or sheep step on the explosives, and the blasts shatter the calm, residents say.

Local people are afraid that the militants, who long used the frontier near Jarabulus to transfer weapons and fighters, will sneak over and carry out a devastating assault.

“We can hear them digging at night, with bulldozers,” said 34-year-old Suliman Kankilic, a local trader. He and other residents think the militants could be digging trenches or a tunnel to infiltrate Turkish territory.

“We wish the army would take over the border towns in Syria, so that we would be safe,” said 42-year-old Mahmut Ozkan, the owner of a kebab restaurant in the area where a Turkish soldier was killed by jihadists on July 22.

Still, the majority of the Turkish public is opposed to further involvement by their country in the Syrian conflict, according to public-opinion surveys. Turkish troops have halted all border crossings in this area since July 25, residents say.

On Friday, the al-Qaeda-linked Jabhat al-Nusra group said it had abducted members of a U.S.-trained rebel faction in northern Syria. The American-backed group, known as Division 30, had announced a day earlier that its commander, Nadim al-Hassan, had been captured by the al-Qaeda affiliate.

The kidnappings underscored the weakness of the moderate rebels — most from the Free Syrian Army — that the United States and Turkey hope will protect the future buffer zone.

At a teahouse in Karkamis, patrons mocked the fecklessness of the moderate rebels, with two of the customers saying they had seen the rebels flee recently when challenged at the Jarabulus-Karkamis crossing.

“When the Islamic State came to the crossing, they didn’t even have to shoot. The Free Syrian Army just ran,” said 45-year-old Matin Damer.

Sipping their tea in the 100-degree heat, the other patrons laughed.

Rami Zayat contributed to this report.

Read more:

How Turkey became the shopping mall for the Islamic State

Turkey’s messy war in the Middle East, explained

The many complications of the U.S. establishing a “safe zone” in Syria