ON THE TURKEY–SYRIA BORDER — For months, an employee at an internet café not far from the Turkish-Syrian border spent much of his time making fake IDs for the Islamic extremists pouring in from abroad. Some came with little more than the clothes on their backs; others sauntered into the unassuming shop like wealthy tourists, sporting brand-new military boots. The employee gave them fake Syrian passports or ID cards that made them into doctors or aid workers, happy to help the jihadis make their way across the border to join the fight against the regime of Bashar al-Assad.

Today, the employee has a new task: making IDs to aid the departure of those same foreign fighters from a country that has devolved into a hotbed of extremism.

"Now I'm helping people to get out of Syria, not to get in," the employee said in an interview near the internet café, speaking on condition that it not be described in detail and that he not be named. He had helped a handful of people so far — by giving them fake Syrian passports that they used to leave for other countries — and said he hoped there would be more. A Syrian and a former fighter himself, the employee, like many of his countrymen, had grown disgusted with the foreign jihadis he once thought were a boon to the rebel cause: with the beheadings, the kidnappings, the suicide bombings. "We don't need them in Syria," he said. "I think they should leave."

Facing a sudden backlash in Syria, some foreign fighters are now doing just that — dropping their weapons and fleeing the war — according to rebels, activists and analysts tracking the conflict.

As of late January, there were 7,000 foreigners fighting with the opposition in Syria, James Clapper, the U.S. director of national intelligence, told a congressional hearing at the time. They come from across the world: Saudi Arabia and Chechnya, Europe and Iraq. Most do their best to stay off the radar, and that's especially true of the ones who hope to return home without being arrested by wary authorities, making it difficult to determine how many have given up on the war of late. Contacted through intermediaries, several former fighters refused to consider interview requests.

One opposition coordinator who channels military support to rebel groups claimed that hundreds of foreign fighters had left Syria since early January. Hundreds more, he said, were stuck in Syria with no good way to leave. Some had brought wives from abroad or married Syrians and were concerned about their families, he said. Others had surrendered their passports to their commanders — and all were wary of being arrested even if they did find a way to get home. "They have no place to go," he said.

Many foreign fighters have landed themselves on terror watch lists — and countries from Belgium and the U.K. to Tunisia have been aggressive in arresting those they catch returning from Syria's war. Western officials, meanwhile, have increasingly warned that these fighters pose a global threat. In his January testimony, Clapper said that some foreign fighters in Syria were being trained to carry out terrorist attacks at home. He compared the country to the lawless tribal areas of Pakistan that al-Qaeda's key leadership has long used as a base.

Foreign fighters also fear repercussions from their colleagues if they attempt to leave the fight. The opposition coordinator said some foreign fighters had recently been executed by their commanders, who accused them of being traitors and thieves. Like others in the opposition who relayed similar accounts, he thought the real motive for the killings was the fighters' intent to leave. The commanders, he said, "are trying to find excuses for killing people who thought about leaving."

As one Turkey-based NGO worker who sends aid to Syria put it, "These are guys who don't seem like they take rejection very well."

Many of the foreign fighters have joined the Islamic State of Iraq and Syria, or ISIS, the al-Qaeda-inspired faction known for kidnapping western aid workers and journalists and imposing a reign of terror on residents in the areas it controls. ISIS was surging in strength inside the rebellion until a backlash against the group erupted in early January. Protesters hit the streets against ISIS across its northern Syria stronghold, while moderate rebels launched offensives against it that quickly flared into an internal war. Even hardline Islamist groups have since joined the fight against ISIS. On Monday, the leader of Jabhat al-Nusra, al-Qaeda's official franchise in Syria, issued an ultimatum threatening to expel ISIS from the region if it didn't accept mediation to end the clashes.

The infighting has weakened ISIS. It has also put foreign fighters on notice in Syria — with ISIS known for being dominated by foreign jihadis, they have become symbols of its worst excesses. They're also easy for locals to spot. "In ISIS circles, there is a widespread perception that [foreign fighters] are being singled out for targeting" by rival rebels, said Aymenn Jawad Al-Tamimi, a fellow at the Middle East Forum who studies jihadi groups in Syria.

Al-Tamimi added that rumors had been swirling among foreign fighters that they and even their families were under threat. "Regardless of whether these allegations are true, the perception is what matters, and many [foreign fighters] are undoubtedly afraid and want to leave Syria," he said. Others, he said, saw the new war against them as a reason to buckle down and fight. ISIS still retains considerable strength in Syria, and foreign fighters continue to maintain a heavy presence in opposition-held territory.

Many foreign fighters saw the war in Syria through a hardline sectarian lens — in their view, they were coming to aid fellow Sunni Muslims in the struggle against a Shiite-aligned regime. "The infighting has likely changed the calculus of some of these guys: 'I went here to fight the regime for the glorious jihad, and ended up fighting other Sunni Muslims,'" said Aaron Zelin, a specialist on global jihadi movements at the Washington Institute for Near East Policy. "That's one reason I don't think the numbers of Sunni foreign fighters will continue to spike in Syria. I think the numbers have already likely peaked, and it's possible they're going to decline."

Within days of the rebel offensive against ISIS in January, some foreign fighters were trying to find their way out of Syria, said the leader of a moderate brigade in Idlib province called the Martyrs of Kafr Awead, who goes by the nickname Abu Ahmed. He said a group of five Saudi nationals who had been fighting with ISIS asked for his help in reaching Turkey. They were afraid to head to the border on their own, he said — wary of being apprehended by rival rebels on the one hand, and by their former ISIS colleagues on the other. "Foreign fighters are targeted more than anyone else," Abu Ahmed said. "There are a lot of people leaving."

Some activists inside Syria have tried to help that process along. One former protest organizer from the eastern city of Raqqa, which is run by ISIS, said he and his friends had spent hours trying to convince foreign fighters to leave the country, one by one: "We sat with them. And we started to tell them, 'Are you here to help the Syrian people? But your organization is arresting people, kidnapping people. It's forcing the niqab on people. It's forcing people to pray.'"

If the fighters weren't convinced by this, said the activist, who asked not to be named for safety concerns, he told them they should focus instead on imposing their fundamentalist vision at home. He said he'd told Saudis about the expats who cavorted in their cities' high-rise hotels and even showed a disbelieving Tunisian a YouTube video of bikini-clad women on the beaches there. "I was telling them in a [hardline] Islamic logic. I was using their own machinery," he said.

The activist said that he and his friends had convinced some fighters to return to Iraq, while others had made their way to Turkey to head back home. But many were too afraid, he added — told that anyone who leaves ISIS is an unbeliever who should be killed. "Some of them were manipulated," he said. "They came on the basis that they were here to support the Syrian people. But they were surprised to find out that ISIS has a lot of similarities to the Syrian regime in terms of oppressing the public."

The activist said he was eventually forced to flee to Turkey under threat from ISIS commanders.

Some Syrians complained that the international community was leaving the problem of the foreign fighters, as they saw it, in their laps. "These governments are not trying to question them for going to Syria. But if they try to go out, they will arrest them," said Abdulrahman Jaloud, an activist from Deir al-Zour, another city with a heavy ISIS presence.

"They will fight again if they can't go back to their home countries," said Samer Kanjo, an activist from Aleppo.

Zelin, of the Washington Institute, said many governments had made it clear that the foreign fighters are not welcome back. "They want to wash their hands of these people," he said. "The calculus is that these are people who are going [to Syria] to die."