(BBC) -- The BBC has uncovered details of a secret deal that let hundreds of IS fighters and their families escape from Raqqa under the gaze of the US and British-led coalition and Kurdish-led forces who control the city.
A convoy included some of IS's most notorious members and -- despite reassurances -- dozens of foreign fighters. Some of those have spread out across Syria, even making it as far as Turkey.
Lorry driver Abu Fawzi thought it was going to be just another job.
He drives an 18-wheeler across some of the most dangerous territory in northern Syria. Bombed-out bridges, deep desert sand, even government forces and so-called Islamic State fighters don't stand in the way of a delivery.
But this time, his load was to be human cargo. The Syrian Democratic Forces (SDF), an alliance of Kurdish and Arab fighters opposed to IS, wanted him to lead a convoy that would take hundreds of families displaced by fighting from the town of Tabqa on the Euphrates river to a camp further north.
The job would take six hours, maximum -- or at least that's what he was told.
But when he and his fellow drivers assembled their convoy early on 12 October, they realised they had been lied to.
Instead, it would take three days of hard driving, carrying a deadly cargo - hundreds of IS fighters, their families and tonnes of weapons and ammunition.
Abu Fawzi and dozens of other drivers were promised thousands of dollars for the task but it had to remain secret.
The deal to let IS fighters escape from Raqqa -- de facto capital of their self-declared caliphate -- had been arranged by local officials. It came after four months of fighting that left the city obliterated and almost devoid of people. It would spare lives and bring fighting to an end. The lives of the Arab, Kurdish and other fighters opposing IS would be spared.
But it also enabled many hundreds of IS fighters to escape from the city. At the time, neither the US and British-led coalition, nor the SDF, which it backs, wanted to admit their part.
Has the pact, which stood as Raqqa's dirty secret, unleashed a threat to the outside world - one that has enabled militants to spread far and wide across Syria and beyond?
Great pains were taken to hide it from the world. But the BBC has spoken to dozens of people who were either on the convoy, or observed it, and to the men who negotiated the deal.
In a greasy yard in Tabqa, underneath a date palm, three boys are busy at work rebuilding a lorry engine. They are covered in motor oil. Their hair, black and oily, stands on end.
Near them is a group of drivers. Abu Fawzi is at the centre, conspicuous in his bright red jacket. It matches the colour of his beloved 18-wheeler. He's clearly the leader, quick to offer tea and cigarettes. At first he says he doesn't want to speak but soon changes his mind.
He and the rest of the drivers are angry. It's weeks since they risked their lives for a journey that ruined engines and broke axles but still they haven't been paid. It was a journey to hell and back, he says.
"We were scared from the moment we entered Raqqa," he says. "We were supposed to go in with the SDF, but we went alone. As soon as we entered, we saw IS fighters with their weapons and suicide belts on. They booby-trapped our trucks. If something were to go wrong in the deal, they would bomb the entire convoy. Even their children and women had suicide belts on."
The Kurdish-led SDF cleared Raqqa of media. Islamic State's escape from its base would not be televised.
Publicly, the SDF said that only a few dozen fighters had been able to leave, all of them locals.
But one lorry driver tells us that isn't true.
Another driver says the convoy was six to seven kilometres long. It included almost 50 trucks, 13 buses and more than 100 of the Islamic State group's own vehicles. IS fighters, their faces covered, sat defiantly on top of some of the vehicles.
Footage secretly filmed and passed to us shows lorries towing trailers crammed with armed men. Despite an agreement to take only personal weapons, IS fighters took everything they could carry. Ten trucks were loaded with weapons and ammunition.
The drivers point to a white truck being worked on in the corner of the yard. "Its axle was broken because of the weight of the ammo," says Abu Fawzi.
This wasn't so much an evacuation - it was the exodus of so-called Islamic State.
The SDF didn't want the retreat from Raqqa to look like an escape to victory. No flags or banners would be allowed to be flown from the convoy as it left the city, the deal stipulated.
It was also understood that no foreigners would be allowed to leave Raqqa alive.
Back in May, US Defence Secretary James Mattis described the fight against IS as a war of "annihilation"."Our intention is that the foreign fighters do not survive the fight to return home to north Africa, to Europe, to America, to Asia, to Africa. We are not going to allow them to do so," he said on US television.
But foreign fighters -- those not from Syria and Iraq - were also able to join the convoy, according to the drivers. One explains:
"There was a huge number of foreigners. France, Turkey, Azerbaijan, Pakistan, Yemen, Saudi, China, Tunisia, Egypt..."
Other drivers chipped in with the names of different nationalities.
In light of the BBC investigation, the coalition now admits the part it played in the deal. Some 250 IS fighters were allowed to leave Raqqa, with 3,500 of their family members.
"We didn't want anyone to leave," says Col Ryan Dillon, spokesman for Operation Inherent Resolve, the Western coalition against IS.
"But this goes to the heart of our strategy, 'by, with and through' local leaders on the ground. It comes down to Syrians -- they are the ones fighting and dying, they get to make the decisions regarding operations," he says.
While a Western officer was present for the negotiations, they didn't take an "active part" in the discussions. Col Dillon maintains, though, that only four foreign fighters left and they are now in SDF custody.
As it left the city, the convoy would pass through the well-irrigated cotton and wheat fields north of Raqqa. Small villages gave way to desert. The convoy left the main road and took to tracks across the desert. The trucks found it hard going, but it was much harder for the men behind the wheel.
A friend of Abu Fawzi's rolls up the sleeve of his tunic. Underneath, there are burns on his skin. "Look what they did here," he says.
According to Abu Fawzi, there were three or four foreigners with each driver. They would beat him and call him names, such as "infidel", or "pig".
They might have been helping the fighters escape, but the Arab drivers were abused the entire route, they say. And threatened.
"They said, 'Let us know when you rebuild Raqqa - we will come back,'" says Abu Fawzi. "They were defiant and didn't care. They accused us of kicking them out of Raqqa."
A female foreign fighter threatened him with her AK-47.
Shopkeeper Mahmoud doesn't get intimidated by much.
It was about four in the afternoon when an SDF convoy drove through his town, Shanine, and everyone was told to go indoors.
"We were here and an SDF vehicle stopped by to say there was a truce agreement between them and IS," he says. "They wanted us to clear the area."
He is no fan of IS, but he couldn't miss a business opportunity - even if some of the 4,000 surprise customers driving through his village were armed to the teeth.
A small bridge in the village created a bottleneck so the IS fighters got out and went shopping. After months of fighting and taking cover in bunkers, they were pale and hungry. They filed into his shop and, he says, they cleared his shelves.
"A one-eyed Tunisian fighter told me to fear God," he says. "In a very calm voice, he asked why I had shaved. He said they would come back and enforce Sharia once again. I told him we have no problem with Sharia laws. We're all Muslims."
Instant noodles, biscuits and snacks - they bought everything they could get their hands on.
They left their weapons outside the shop. The only trouble he had was when three of the fighters spied some cigarettes -- contraband in their eyes -- and tore up the boxes.
"They didn't appropriate anything, nothing at all," he says.
"Only three of them went rogue. Other IS fighters even chastised them."
He says IS paid for what they took.
"They hoovered up the shop. I got overwhelmed by their numbers. Many asked me for prices, but I couldn't answer them because I was busy serving other people. So they left money for me on my desk without me asking."
Despite the abuse they suffered, the lorry drivers agreed - when it came to money, IS settled its bills.
Says Abu Fawzi with a smile.
North of the village, it's a different landscape. A lonely tractor ploughs a field, sending a plume of dust and sand into the air that can be seen for miles. There are fewer villages, and it's here that the convoy sought to disappear.
In Muhanad's tiny village, people fled as the convoy approached, fearing for their homes - and their lives.
But suddenly, the vehicles turned right, leaving the main road for a desert track.
"Two Humvees were leading the convoy ahead," says Muhanad. "They were organising it and wouldn't let anyone pass them."
As the convoy disappeared into the haze of the desert, Muhanad felt no immediate relief. Almost everyone we spoke to says IS threatened to return, its fighters running a finger across their throats as they passed by.
"We've been living in terror for the past four or five years," says Muhanad.
Along the route, many people we spoke to said they heard coalition aircraft, sometimes drones, following the convoy.
From the cab of his truck, Abu Fawzi watched as a coalition warplane flew overhead, dropping illumination flares, which lit up the convoy and the road ahead.
The coalition now confirms that while it did not have its personnel on the ground, it monitored the convoy from the air.
Past the last SDF checkpoint, inside IS territory - a village between Markada and Al-Souwar - Abu Fawzi reached his destination. His lorry was full of ammunition and IS fighters wanted it hidden.
When he finally made it back to safety, he was asked by the SDF where he'd dumped the goods.
"We showed them the location on the map and he marked it so uncle Trump can bomb it later," he says.
Raqqa's freedom was bought with blood, sacrifice and compromise. The deal freed its trapped civilians and ended the fight for the city. No SDF forces would have to die storming the last IS hideout.
But IS didn't stay put for long. Freed from Raqqa, where they were surrounded, some of the group's most-wanted members have now spread far and wide across Syria and beyond.
The men who cut fences, climb walls and run through the tunnels out of Syria are reporting a big increase in people fleeing. The collapse of the caliphate is good for business.
"In the past couple of weeks, we've had lots of families leaving Raqqa and wanting to leave for Turkey. This week alone, I personally oversaw the smuggling of 20 families," says Imad, a smuggler on the Turkish-Syrian border.
"Most were foreign but there were Syrians as well."
He now charges $600 (£460) per person and a minimum of $1,500 for a family.
In this business, clients don't take kindly to inquiries. But Imad says he's had "French, Europeans, Chechens, Uzbek".
"Some were talking in French, others in English, others in some foreign language," he says.
Walid, another smuggler on a different stretch of the Turkish border, tells the same story.
"We had an influx of families over the past few weeks," he says. "There were some large families crossing. Our job is to smuggle them through. We've had a lot of foreign families using our services."
As Turkey has increased border security, the work has become more difficult.
However, Walid says it's a different situation for senior IS figures.
"Those highly placed foreigners have their own networks of smugglers. It's usually the same people who organised their access to Syria. They co-ordinate with one another."
Smuggling didn't work out for everyone. Abu Musab Huthaifa was one of Raqqa's most notorious figures. The IS intelligence chief was on the convoy out of the city on 12 October.
But now he is behind bars, and his story reflects the final days of the crumbling caliphate.
Islamic State never negotiates. Uncompromising, murderous - this is an enemy that plays by a different set of rules.
At least that's how the myth goes.
But in Raqqa, it behaved no differently from any other losing side. Cornered, exhausted and fearful for their families, IS fighters were bombed to the negotiating table on 10 October.
"Air strikes put pressure on us for almost 10 hours. They killed about 500 or 600 people, fighters and families," says Abu Musab Huthaifa.
Footage of the coalition air strike that hit one neighbourhood of Raqqa on 11 October shows a human catastrophe behind enemy lines. Amid the screams of the women and children, there is chaos among the IS fighters. The bombs appear especially powerful, especially effective. Activists claim that a building housing 35 women and children was destroyed. It was enough to break their resistance.
"After 10 hours, negotiations kicked off again. Those who initially rejected the truce changed their minds. And thus we left Raqqa," says Abu Musab.
There had been three previous attempts to negotiate a peace deal. A team of four, including local Raqqa officials, now led the talks. One brave soul would cross the front lines on his motorbike relaying messages.
"We were only to leave with our personal weapons and leave all heavy weapons behind. But we didn't have heavy weapons anyway," Abu Musab says.
Now in jail on the Turkish-Syrian border, he has revealed details of what happened to the convoy when it made it safely to IS territory.
He says the convoy went to the countryside of eastern Syria, not far from the border with Iraq.
Thousands escaped, he says.
Abu Musab's own attempted escape serves as a warning to the West of the threat from those freed from Raqqa.
How could one of the most notorious of IS chiefs escape through enemy territory and almost evade capture?
"I remained with a group which had set its mind on making its way to Turkey," Abu Musab says.
Islamic State members were wanted by everyone else outside the group's shrinking area of control; that meant this small gathering had to pass through swathes of hostile territory.
"We hired a smuggler to navigate us out of SDF-controlled areas," Abu Musab says.
At first it went well. But smugglers are an unreliable lot. "He abandoned us midway. We were left to fend for ourselves in the midst of SDF areas. From then on, we disbanded and it was every man for himself," says Abu Musab.
He might have made it to safety if only he'd paid the right person or maybe taken a different route.
The other path is to Idlib, to the west of Raqqa. Countless IS fighters and their families have found a haven there. Foreigners, too, also make it out - including Britons, other Europeans and Central Asians. The costs range from $4,000 (£3,000) per fighter to $20,000 for a large family.
Abu Basir al-Faransy, a young Frenchman, left before the going got really tough in Raqqa. He's now in Idlib, where he says he wants to stay.
The fighting in Raqqa was intense, even back then, he says.
"We were front-line fighters, waging war almost constantly [against the Kurds], living a hard life. We didn't know Raqqa was about to be besieged."
Disillusioned, weary of the constant fighting and fearing for his life, Abu Basir decided to leave for the safety of Idlib. He now lives in the city.
He was part of an almost exclusively French group within IS, and before he left some of his fellow fighters were given a new mission.
Much is hidden beneath the rubble of Raqqa and the lies around this deal might easily have stayed buried there too.
The numbers leaving were much higher than local tribal elders admitted. At first the coalition refused to admit the extent of the deal.
The Kurdish-led Syrian Democratic Forces, somewhat improbably, continue to maintain that no deal was done.
And this may not even have been about freeing civilian hostages. As far as the coalition is concerned, there was no transfer of hostages from IS to coalition or SDF hands.
And despite coalition denials, dozens of foreign fighters, according to eyewitnesses, joined the exodus.
The deal to free IS was about maintaining good relations between the Kurds leading the fight and the Arab communities who surround them.
It was also about minimising casualties. IS was well dug in at the city's hospital and stadium. Any effort to dislodge it head-on would have been bloody and prolonged.
The war against IS has a twin purpose: first to destroy the so-called caliphate by retaking territory and second, to prevent terror attacks in the world beyond Syria and Iraq.
Raqqa was effectively IS's capital but it was also a cage - fighters were trapped there.
The deal to save Raqqa may have been worth it.
But it has also meant battle-hardened militants have spread across Syria and further afield -- and many of them aren't done fighting yet.
All names of the people featured in the report have been changed.