Supporters of the Turkish prime minister wave Turkey's national flag and the old Syrian flag. (AFP/Getty Images)

Before their blitz into Iraq earned them the title of the Middle East’s most feared insurgency, the jihadists of the Islamic State treated this Turkish town near the Syrian border as their own personal shopping mall.

And eager to aid any and all enemies of Syrian President Bashar al-Assad, Turkey rolled out the red carpet.

In dusty market stalls, among the baklava shops and kebab stands, locals talk of Islamist fighters openly stocking up on uniforms and the latest Samsung smartphones. Wounded jihadists from the Islamic State and the al-Nusra Front — an al-Qaeda offshoot also fighting the Syrian government — were treated at Turkish hospitals. Most important, the Turks winked as Reyhanli and other Turkish towns became way stations for moving foreign fighters and arms across the border.

“Turkey welcomed anyone against Assad, and now they are killing, spreading their disease, and we are all paying the price,” said Tamer Apis, a politician in Reyhanli, where two massive car bombs killed 52 people last year. In a nearby city, Turkish authorities seized another car packed with explosives in June, raising fears of an Islamic State-inspired campaign to export sectarian strife to Turkey.

“It was not just us,” Apis said. “But this is a mess of Turkey’s making.”

A Turkish military armored vehicle patrols on the border of Turkey and Syria. (Umit Bektas /REUTERS)

The U.S. military is back in action over the skies of Iraq, launching airstrikes against the Islamist militants who have taken control of large swaths of Iraq and Syria. But for many months, the militants were able to grow in power partly by using the border region of a NATO member — Turkey — as a strategically vital supply route and entry point to wage their war.

Alarmed by the growing might of the Islamic State, Turkey has started cracking down. Working with the United States and European governments, Turkish officials have enacted new safeguards to detain foreign fighters trying to get into Syria and launched a military offensive aimed at curtailing the smuggling of weapons and supplies across the border.

But in a region engulfed by a broadening conflict, Turkey is also reaping what it sowed. It is engaging in border shootouts with rebels it once tactically aided. It is confronting spillover violence, a cutoff in its trade routes and a spreading wave of fear in Turkish towns as the Islamic State wins over defectors from rival opposition groups.

And despite the new measures, the Islamic State is still slipping through Turkish nets — raising doubts about international efforts to put a stranglehold on a radical Sunni group known for public crucifixions and the beheading of enemies.

“It is not as easy to come into Turkey anymore,” Abu Yusaf, a 27-year-old senior security commander for the Islamic State, said in a recent interview conducted in the back seat of a moving white Honda in Reyhanli. “I myself had to go through smugglers to get here, but as you see, there are still ways and methods.”

Wearing a polo shirt and white baseball cap to blend in on the more secular streets of Turkey, Yusaf, the nom de guerre of the European-born fighter who joined the group 21 / 2 years ago, added: “We don’t believe in countries . . . breaking and destroying all borders is our aim. What matters are Islam and a Sunni reign.”

Asked about the United States’ role in the region, Yusaf said, “We don’t fear the U.S., we only fear God. We fight whoever are fighting us. If the U.S. hits us with flowers, we will hit them back with flowers. But if they hit us with fire, we will hit them back with fire, also inside their homeland. This will be the same with any other Western country.”

The British Royal Air Force drops further aid to refugees in central and northern Iraq overnight on August 12, the third day of aid delivery. (Crown Copyright 2014 via YouTube)

For Turkey, it was not supposed to be this way.

Initially a close Assad ally, Turkish Prime Minister Recep Tayyip Erdogan broke with Damascus after the Syrian leader launched a bloody assault on opponents in 2011. Erdogan quickly emerged as a leading voice calling for international action to topple the Syrian leader.

But for Erdogan, a charismatic autocrat once filled with notions of building a neo-Ottoman sphere of influence across the Middle East, the move to tactically support a broad swath of the Syrian opposition has backfired, resulting in one of a series of recent setbacks for him at home and abroad.

During its push into the northern Iraqi city of Mosul in June, the Islamic State seized 80 Turkish hostages — including a gaggle of diplomats — 41 of whom are still being held. More than 1 million refugees have poured into Turkey since the start of the Syrian conflict, costing the government more than $3 billion. Billions more have been lost in business and trade across its borders with Syria and Iraq.

“This is destroying us,” said Huseyin Surucu, owner of Rey-Tur, a Reyhanli transport company that has seen its business plunge by 60 percent since the start of the Syrian conflict. One bomb blast that hit the city last year went off several feet from his company, killing a family friend. “We are all afraid because we know more trouble is coming.”

Turkish officials have publicly offered support for more mainstream factions of the Syrian opposition. Yet only in more recent stages of the conflict has it labeled some extremist factions as terrorist groups. And given the difficulty of accurately assessing loyalties among the opposition, Turkey indiscriminately allowed weapons and fighters to flow across the border, Western diplomats, local officials and security experts say.

Of massive concern are thousands of increasingly radicalized foreign fighters, including many carrying U.S. and European passports, who have gone to fight in Syria. One senior Turkish official who declined to be identified blamed Western allies for not fully cooperating in the hunt to stop “the wrong ones” from crossing the border.

Citing privacy laws, for instance, European governments would often provide limited information to Turkish intelligence about suspects. “They were not giving us all the information they had,” the official said.

But that has changed. Since the fall of Mosul in June, the Europeans and Americans have been sharing more details, he said, and the Turks have stepped up detentions of suspected foreign fighters. The Turks refuse to disclose the number of recent arrests and repatriations.

Meanwhile, Turkish calculations in the Syrian conflict are fast evolving. The Turks have started cooperative talks with the Democratic Union Party (PYD), a Kurdish separatist group whose brothers in arms have fought a long guerrilla war against Turkey. The reason for the possible new alliance: The PYD controls a swath of Syria and is fighting against the Islamic State.

But Turkey’s about-face may be too little, too late.

Yusaf, the Islamic State commander who traveled to Reyhanli from Syria for an interview with The Washington Post, suggested that the group had the Turks to thank in part for its current success.

“We used to have some fighters — even high-level members of the Islamic State — getting treated in Turkish hospitals,” he said. “And also, most of the fighters who joined us in the beginning of the war came via Turkey, and so did our equipment and supplies.”

He conceded that the recent crackdown had made it more difficult to continue using Turkey as a supply route. But he added that the group had grown so strong in Iraq — where it won fast allies among the Sunni tribes — that it no longer needed to rely on the Turkish border.

“Now we are getting enough weapons from Iraq, and there is enough to buy even within Syria,” he said. “There is no real need to get things from outside anymore.”

Meanwhile, Turkey remains a lucrative market for bootlegged gasoline coming from Syria and Iraq, some of which is almost surely coming from areas controlled by the Islamic State. In Haji Pasha, a Turkish town in the shadow of the hilly Syrian border, dozens of farmers and laborers have switched jobs. Now, they are gasoline smugglers.

On a recent drive through town, Turks on tractors were pulling wagonloads of plastic 60-liter tanks to fill up with smuggled Syrian and Iraqi gasoline being sold for a fraction of legal retail prices. Asked whether the gas
was coming from Islamic State-controlled zones, a 35-year-old businessman-turned-smuggler who gave his name as Takim, said: “Here, we do not ask those kinds of questions.”

New sweeps by Turkish authorities have prevented smugglers from hauling Syrian and Iraqi gasoline in over land. So ingenious townspeople have built dozens of makeshift underground pipelines that run under the border. On a recent afternoon, plumes of smoke billowed up from one pipeline being destroyed by the Turkish military.

“That’s okay,” said Tahir, 39, another self-described smuggler, standing on the roof of a friend’s house to watch the Turkish troops in action. “We’ve got many more.”