A secret internment camp for former Islamic State militants and their families has been established in Syria.
Some 300 defectors and captured combatants, including many Europeans, are being held at the camp operated by the rebel group Jaysh al-Tahrir.
Its commander, Mohammad al-Ghabi, told the BBC: "We tried to rehabilitate them and alter their state of minds."
"Those who wished to return home were allowed to call their embassies and co-ordinate with them through us."
Among the group are French, Dutch and Polish nationals, as well as foreign fighters from North Africa and across the Middle East and Central Asia.
The men, women and children are being held in a village in rural northern Syria.
Mr Ghabi said the numbers were growing as IS collapsed, thanks to a Turkish-supported rebel offensive against the group in northern Syria called "Operation Euphrates Shield".
"IS has been falling apart for the past seven or eight months, according to the defectors we spoke to. However, Operation Euphrates Shield further degraded IS and led to its dismemberment following the rapid advances of our forces," he added.
A BBC team was unable to visit the camp, but obtained material from inside. It has basic facilities and the prisoners there say they are being well cared for, but many want to leave.
One former IS fighter there goes by the name of Abu Sumail.
He travelled from his native Netherlands two years ago, going first to Belgium, then to Gaziantep in Turkey. He said he disguised himself as a "party guy" on holiday, to avoid detection by the intelligence services.
But getting into Syria was much easier than leaving.
Speaking of his disappointment with life inside IS-held territory, he said: "They treat us very bad, especially people from another country.
"It's very hard for us to live there - it's not our lifestyle because we are used to a lot of things and then we come there and they directly start to treat you hard.
"You give your life to them, so they are going to start to take control of your life. They use you for bad stuff."
The BBC has also learned that an underground railroad is being created in Syria, with other rebel groups and British and European intelligence services, to find, capture and return IS supporters.
Inside the Syrian city of Raqqa, the de facto IS capital, fighters have begun to send videos and personal statements to rebel groups, in the hope of escaping with their families.
At least half a dozen foreign fighters have made it out already, and are facing imprisonment back in Europe, according to rebel groups.
Mr Ghabi said that not everyone would be allowed to leave.
"Those who didn't want to go back or had committed crimes are being referred to a Sharia court, which rules by [Islamic] law and punishes according to the gravity of crime committed."
Some could be executed, he warned, and added that the window of opportunity for defectors to cross to the rebels was closing fast, as IS continues to lose territory and its proto-state crumbles.