On a warm night in August, not long after the end of Ramadan, a Syrian refugee named Abu Salma boarded a bus in the Turkish border town of Kilis wearing his best clothes—crisp new jeans and a collared shirt.

As far as his family knew, he was traveling to a nearby wedding. In reality, he was headed to Urfa, a conservative, middle-class town in southern Turkey, where he met three other Syrians for a secret, one-time mission: to kidnap a group of men smuggling foreign fighters into Syria for the Islamic State (ISIS).

As the United States and the West continue their war against the makeshift caliphate, Turkey has found itself in a precarious situation. The government’s ultimate goal is the defeat of Syrian President Bashar al-Assad. But the pursuit of that goal has created a virtual safe haven for ISIS fighters going back and forth across the border. Those fighters are aligned against Assad, but they’re no friend of the Turkish state either. Last summer, for instance, ISIS militants kidnapped 49 Turkish consulate workers in the Iraqi city of Mosul.

Syrian refugees cross the Turkish border illegally near Kilis. AFP/Getty Images/ OZAN KOSE

Analysts say Ankara has begun a delicate dance in recent months, combating (but not defeating) ISIS along the border in an effort to please its Western allies, keep its citizens safe and maintain pressure on Assad. Allegedly lending a hand: small bands of Syrian refugees turned makeshift spies, operating with limited control from Turkish intelligence agencies.

The Turkish government declined to comment for this story. But in more than a dozen interviews across southern Turkey, Syrian refugees say they’ve helped capture ISIS members lurking along the border, offering Turkish authorities both access and cover in case anything went wrong.

Some of these refugees are affiliated with various rebel groups battling ISIS and Assad. Others are ordinary citizens, frustrated with what’s become of their revolution. Abu Salma, a lanky 20-something who works at an electronics shop, says he’s one such man. His story offers rare glimpse into the murky world of espionage taking place along one of the world’s most dangerous borders.

It’s been several months since his operation ensued, and Abu Salma recalls that night with a mixture of pride, fear and bewilderment. For his safety, he asked to be identified only by his nom de guerre. His story could not be independently verified because of the shadowy nature of the task. But it mirrors the accounts offered by other Syrian refugees who say they’re working with Turkish authorities, fighting ISIS along the border.

As he boarded the bus bound to Urfa, Abu Salma says he knew little about his mission except that he was fighting against ISIS. But that was enough. “I would do anything to stop those who have stolen our revolution,” he says.

Abu Salma says he heard about the operation the night before from a middle-aged acquaintance we’ll call Firas; he’s the ringleader of the makeshift spy cell in Turkey. The two knew each other back when they lived in their hometown in northern Syria. Years ago, before the revolution, both had once served in Assad’s army, and Abu Salma says Firas thought he’d be a good man for the job.

When Abu Salma stepped off the bus that evening, he found Firas waiting for him with two Syrians he didn’t know. Both were refugees in their mid-20s. They greeted each other with Arab monikers—not their real names—then they walked over to a sedan with tinted windows, which was idling nearby. “Come,” Abu Salma recalls Firas telling them. “I will give you the details on the way.”

A café in the bazaar in Urfa, Turkey. ZUMAPRESS.com/TIPS

Inside the car, Abu Salma says, was a Turkish intelligence officer, who drove them to a café just outside Urfa. There, Abu Salma says, he and his cohorts sat in the back, listening nervously as the officer explained how the operation would work. They were going to a village near the Syrian border, to a small, square house with three rooms and a walled-off courtyard. Two ISIS smugglers were living there. “One Syrian and one Iraqi,” the Mukhabarat officer told them, according to Abu Salma. “And they are probably heavily armed.”

Before they parted, Abu Salma says the intelligence officer gave each a 9-millimeter pistol and a grim warning: “Don’t let anyone escape.”

Hours later, just before midnight, Abu Salma says the four men approached the village on foot. They stopped outside town and waited awhile, standing in the darkness, listening to the sounds of the desert. In a village this small, they reasoned, outsiders would stand out and someone could tip off the militants. They wanted to make sure everyone was asleep.

Around 1 a.m., they quietly snuck through the town and surrounded the house. Just before they entered, one of the men suddenly had cold feet. “He was afraid,” Abu Salma says. “So we told him to be strong, that these men are smuggling foreigners into Syria for Daesh. We told him, ‘Maybe this operation will stop that and release the pressure on our brothers who are fighting inside Syria right now.’”

The man nodded, and three of them scaled the walls while Firas kicked his way through the front door. “It happened so fast,” says Abu Salma.

The four men barged through the bedroom door, firing shots in the air, Abu Salma recalls. The Iraqi went for his gun and they shot him in the leg. The Syrian didn’t move, but they considered shooting him anyway; they worried he might have been wearing a suicide vest. In the end, they held back.

The operation lasted just 15 minutes. Once the smugglers surrendered, Abu Salma says he and his fellow operatives tied them up, blindfolded them and brought them outside, where two Turkish intelligence vehicles were waiting.

After a quick round of excited congratulations, Abu Salma says he and the three other operatives piled back in the Turkish officer’s tinted sedan and rode back to the bus station in silence.

This operation wasn’t the first Turkish-Syrian sting against ISIS, and it probably won’t be the last. In interviews, Syrian refugees with knowledge of missions like Abu Salma’s say hundreds of their countrymen have worked as operatives for Turkish intelligence officers along the border, carrying out kidnapping missions. Others are working for the other side, helping ISIS with its smuggling initiatives.

“We work just like professional intelligence agencies,” says Abu Yazan, a 30-year-old Syrian rebel who was convalescing from battle wounds in a small state-run hospital near the border.

Abu Yazan says he’s fighting against ISIS in Syria and Turkey, but won’t disclose much more about his handlers. “Without Turkish assistance,” he says, “operations here are much more difficult.”

Asking that only his nom de guerre be used for fear of reprisals, Abu Yazan says his group and others also rely on a network of dozens of Turkish informants and strongmen to assist in planning and whisking detainees back across the border into rebel-held northwestern Syria. In several interviews, Syrians with knowledge of the abductions say Turkish authorities are careful to leave no trace of involvement, for fear of spurring ISIS attacks within its borders.

Some plans take months to carry out, the operatives say. With their help, the refugees turned spies claim that Turkish intelligence officers track ISIS members from the front lines of the Syrian civil war to prosperous Turkish cities, where they often travel to regroup, receive treatment for injuries and coordinate the movement of new foreign recruits across the border.

Armored police vehicles patrol the streets in Gaziantep. REUTERS/Osman Orsal

Late last month, for instance, the Turkish police raided a home near the large border city of Gaziantep. Inside, they found a cache of weapons and suicide vests. The week before, the police had found in the same area an even bigger arsenal, including 330 pounds of C4 explosives and 20 suicide vests. The arsenals, Turkish authorities say, belonged to ISIS.

These raids are relatively new. For two years, analysts say the Turkish government looked the other way as jihadis built a human smuggling pipeline running from the airports of Istanbul to the bus stations in the country’s south along the Syrian frontier. Not long ago, it was common to see young men from Western and Arab countries sporting the long hair and bushy beards favored by jihadis wandering openly around bus stations and budget hotels in Turkey’s border areas.

Now ISIS has to operate with greater secrecy, as Turkey’s been under pressure from its NATO allies to crack down on the jihadi group. “Turkey decided to strengthen its border controls and make border crossings much more difficult for the Islamist militants,” says Sinan Ülgen, chairman of the Istanbul-based Center for Economics and Foreign Policy Studies. “The biggest threat is definitely a possible retaliation by ISIS.”

Among the Syrians, however, there’s a tacit understanding that the Turkish authorities tolerate at least some ISIS members in their country. The same goes for the Assad regime, which critics say released hundreds of prisoners, many of whom later joined jihadi groups, during the early days of the civil war in an effort to paint the rebels as religious zealots. A report from the United Nations last week stated that foreign fighters are crossing into Syria and Iraq—a trip that most make through Turkey—on “an unprecedented scale.”

“[ISIS fighters] come here because they feel safe,” Abu Yazan says. “We only care about the biggest criminals from Daesh, such as emirs and top commanders.”

A view of Urfa in southern Turkey. ZUMAPRESS.COM/Ilker Gurer

Nevertheless, Turkey is well-aware of the internal jihadi threat from ISIS. Militants from the jihadi group swept across northern and western Iraq in June and kidnapped the Turkish consulate workers in Mosul. But if the hostage crisis made Turkey realize the severity of the problem, it was their mysterious release in September that enabled them to carry out what some observers say has been a wider crackdown, with less fear of an ISIS retaliation.

“After the safe release of the hostages, Ankara was able to step up its domestic efforts as well for curtailing the ISIS networks within the country, including their financing and recruiting networks,” says Ülgen.

It’s still unclear how the hostages were freed. But shortly after their release, Turkish President Recep Tayyip Erdogan coyly hinted at an explanation. “You probably cannot expect us to publicly divulge what intelligence agencies do in their business, but the end result is that 49 diplomatic and consular staff have been freed,” he told the Council on Foreign Relations. “Some say maybe there’s been an exchange, you might have an exchange. But it also takes an effort to prepare for such a thing.”

Abu Salma believes his operation played a role in the preparation, that the Syrian he helped kidnap was part of the diplomatic exchange. On the border that night, he says his group handed the smugglers over to their Turkish handlers to be interrogated. The Iraqi would remain in Turkish custody, he says Firas told him, but the Syrian would eventually face justice at home.

Weeks passed and Abu Salma resumed his job at an electronics shop. He says he was in sporadic contact with Firas, but not the other two Syrians who had gone back to Syria to fight in Aleppo. He says Firas eventually told him that the Syrian prisoner never made it into rebel custody.

“Then everyone heard about the diplomats,” Abu Salma says, “and I knew then what had happened with our prisoner.”

As Turkey’s spy wars continue, Abu Salma believes he and the men he kidnapped could someday meet again.