Rayan was smashed in the face with a rifle butt and flung head first down concrete steps. Then he was hung from the ceiling by his wrists and beaten. Even then, the torture was not over: it stopped only when he fainted from the excruciating pain of being placed in a tyre while his legs were twisted and wrenched with a stick.

The 37-year-old interior decorator and judo trainer had been among the first to join the protest movement against Syria’s President, Bashar al-Assad. But the torture inflicted on him was not by the regime. It was by rebels supposedly on his side – another grim example of how Syria’s revolution is now consuming its own children.

Rayan is the nickname of Mohammed Oun, a well-known civil rights campaigner in northern Syria. He was held captive by Islamist extremists after taking part in the first large-scale demonstration inside rebel-held Syria against groups like Isis and Jabhat al-Nusra, held by people protesting against their vicious rule in the city of Aleppo.

Speaking in the safety of a town just across the Turkish border, Rayan described how the extremists attacked that brave demonstration, held in the first week of April. He told me of the mounting despair among those who had seen their revolution against the Assad regime hijacked, with the ideals for which they had sacrificed so much now lost. He also spoke of his intention to go back to Aleppo, despite the risks this would entail.

I had first met Rayan in Aleppo during the fierce battle in the summer of 2012 for the country’s richest and largest city. Two Syrian activists and I had gone to pick up Jim Foley and Nicole Tong, friends and fellow journalists, who were staying with Rayan at his home in the Bustan al-Qasr district, an area taken over by regime forces.

I had worked alongside Foley and Tong, covering a number of wars. Foley was kidnapped and murdered on a subsequent visit to Syria, the first of six foreign hostages to be beheaded by “Jhadi John” – the Londoner, Mohammed Emwazi, who has become the grotesque star of the organisation’s slick “snuff” videos. Foley had been kidnapped along with the British photographer, John Cantlie, in autumn 2012. A little later, Tong visited Rayan in Aleppo and told him what had happened.

Ryan was beaten with electric cables by al-Nusra militants

Rayan, softly spoken and good humoured, recalled his own concerns about Foley. “Criminal gangs were kidnapping people and selling them to groups like Daesh [Isis] who were looking for Western people,” he said.

“We knew how violent they were, what they might do. At the time we thought – we hoped – something will be done and Jim will be freed. We were very grateful for foreign journalists coming to the free part of Syria to show the terrible things going on. It was shocking that they and aid workers were being taken prisoner. We were protesting against the way some of these extremist groups were behaving.”

Rayan searched long and hard for Foley but he, along with Cantlie, had been passed repeatedly from one group to another. Later Rayan saw the video of Foley’s death. “It showed what had happened to our revolution. The only foreigners the extremists wanted here were those who would take part in their jihad. Local people in Aleppo were also suffering badly in the hands of these people and we felt we must keep speaking up – we must protest.”

But that came at a cost. Rayan had previously been abducted by the al-Qaeda affiliate, Jabhat al-Nusra – the first time, in November 2013, after he and others objected to their treatment of anyone questioning their version of sharia law. He was subjected to one of their favourite forms of torture, the “aeroplane”, in which victims are suspended from the ceiling and beaten.

Rayan says one militants hit him around the head with a gun before he was held on the floor by another

The activist was released after a few days with a warning. At the time the hardliners did not worry about liberals like Rayan too much: they were on a roll, extending their fiefdom as the Western-backed Free Syrian Army lost ground, men and influence. Al-Nusra and Isis were sometimes in alliance, sometimes fighting each other.

By the beginning of this year, most moderate activists in opposition areas had been forced to flee, been imprisoned or killed. But those who remained decided they must take a stand for the original values of the revolution before it was too late. A demonstration was to be staged in Aleppo, with the organisers declaring that all the differing groups of the revolution would be welcome.

Bari, another activist, said: “The aim was to re-establish the ideal of the revolution – democracy, equality and a united Syria. We could not let this continue, the extremists oppressing the people while Bashar continues to do his own oppression. We wanted there to be a debate about the course of the revolution.”

Bari’s own home town, al-Bab, around 20 miles from Aleppo, was a microcosm of what happened. The moderate rebels took control first; then al-Nusra, which is allied to al-Qaeda, established a presence, and finally came occupation by Isis, and with it a savage regime of shooting, hanging and flogging.

Barry, another activist, said: 'The aim was to re-establish the ideal of the revolution, democracy, equality and a united Syria'

Rayan said that at the Aleppo demonstration at first, there was laughter, camaraderie and cries of “freedom” from the crowd of around 300, just like the early days of the revolution. But then al-Nusra men appeared in trucks, along with some of their supporters. These included members of Hizb ut-Tahrir, a radical Islamic group with an extensive network in the UK. The organisation in the UK has denied any links with Al-Nusra.

Al-Nusra responded to calls for tolerance with their swords, chopping down the green, white and black flags of the revolution. They then turned their swords on the protesters. One of their leaders who tried to calm the situation was screamed at by one of his own fighters, waving a Kalashnikov assault rifle: “You have become an atheist!”

The activists decided to complain about the attacks to the sharia court and Rayan was chosen as their spokesman. As he left court the next day, he was ambushed by three masked men and knocked down with rifle butts. Blindfolded, he was taken to what he thought was a warehouse an hour’s drive away.

Rayan was put in a tiny cell. He then heard a whisper, the prisoner next door had gouged a hole in the wall and desperately wanted to get a message to the outside. He was an officer in the Farouq Brigade, a moderate group which had been accused of killing a leader of a Salafist faction, Dawa al-Islamiyah.

Since his second kidnapping, Cantlie remains the last known Western hostage of Isis. He has been appearing, under duress, to appear in the group’s propaganda videos.

Rayan decided there was no point in being apologetic during his interrogation. “They knew my views, they wouldn’t have believed if I had told them that I had suddenly changed my mind and agreed with them. In any case they brought along an informer who accused me of spying on al-Nusra, being a kuffir [an unbeliever], all kinds of things. So, I was found guilty very quickly.

“At that point the man questioning me took off his mask. Now, I began to feel frightened: if he was willing to show his face to me, I thought for the first time that I wasn’t going to get out alive. There was a tremendous feeling of hopelessness, but I knew I must fight against it.”

In pictures: Syria conflict Show all 40 1 /40 In pictures: Syria conflict In pictures: Syria conflict Syria crisis Syrians carry children amid debris following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis A Syrian man carries a girl on a street covered with dust following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis Syrians react as they stand amid debris following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis A Syrian man carries a girl amid debris following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis An injured Syrian man walks out from the rubble of a destroyed building following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis A Syrian woman makes her way through debris following a air strike by government forces in the northern city of Aleppo In pictures: Syria conflict Syria crisis People stand on the rubble of collapsed buildings at a site hit by what activists said was a barrel bomb dropped by forces loyal to Syria's President Bashar al-Assad, in the Al-Fardous neighbourhood of Aleppo In pictures: Syria conflict Syria crisis Syrian residents stand amid the rubble of destroyed buildings In pictures: Syria conflict Syria crisis A Syrian resident grasps a mattress amid rubble in the al-Firdous neighborhood of the northern city of Aleppo In pictures: Syria conflict Syria crisis A view taken from Tel al-Sawadi shows a large explosion allegedly at the Wadi Deif Syrian army base in northwestern Idlib on May 14, 2014, which opposition fighters have been trying to capture for more than a year. The Syrian Observatory for Human Rights said Islamist rebels detonated explosives planted in a tunnel under the army base killing or injuring dozens. AFP In pictures: Syria conflict Syria crisis A bullet-riddled parking sign stands amid debris in a deserted street leading into the old city of Homs In pictures: Syria conflict Syria crisis A general view shows abandoned buildings on a deserted square in the old city of Homs after Syrian government forces regained control of rebel-controlled areas In pictures: Syria conflict Syria crisis A military vehicle that belongs to the Free Syrian Army is seen in Al-Amariya district in Aleppo In pictures: Syria conflict Syria crisis A mosque is pictured through shattered glass in the old city of Homs, as rebel fighters withdrew from the city centre in line with a negotiated withdrawal deal with the government after having held out under tight siege for nearly two years In pictures: Syria conflict Syria crisis Buses carrying Free Syrian Army fighters leaving Homs. Exhausted and worn out from a year-long siege, hundreds of Syrian rebels left their last remaining bastions in the heart of the central city of Homs under a cease-fire deal with government forces. The exit of some 1,200 fighters and civilians will mark a de facto end of the rebellion in the battered city, which was one of the first places to rise up against President Bashar Assad's rule, earning it the nickname of "capital of the revolution" In pictures: Syria conflict Syria crisis Syrian government forces hold up a portrait of President Bashar al-Assad (L) while others raise the national flag on top of a pole in the old city of Homs In pictures: Syria conflict Syria crisis Forces loyal to Syria's President Bashar al-Assad run through Aleppo's Bustan al-Qasr crossing after their release by rebels. They were freed as part of a larger deal which saw the last remaining Syrian rebels in central Homs city evacuate their positions and free captives in several locations in northern Syria In pictures: Syria conflict Syria crisis A Syrian woman and two children walk past heavily damaged buildings in the northern city of Aleppo In pictures: Syria conflict Syria crisis A man carries a wounded girl following a reported bombardment with explosive-packed "barrel bombs" by Syrian government forces in the al-Mowasalat neighborhood of the northern Syrian city of Aleppo In pictures: Syria conflict Syria crisis A wounded man sits as he is treated at a makeshift hospital following a reported bombardment with explosive-packed "barrel bombs" by Syrian government forces in the al-Sakhour district of the northern city of Aleppo In pictures: Syria conflict Syria crisis Debris rises in what Free Syrian Army fighters and Islamic rebels said was an operation to strike Al-Sahaba checkpoint, which is considered a gateway to Al-Dayf valley, and remove forces loyal to Syria's President Bashar Al-Assad in Maarat Al-Nouman, Idlib province In pictures: Syria conflict Syria crisis Men try to put out fire at a site hit by what activists said was an air strike by forces loyal to Syria's President Bashar al-Assad in the town of Azaz, north of Aleppo, near the border with Turkey In pictures: Syria conflict Syria crisis Civil Defence members try to put out fire In pictures: Syria conflict Syria crisis Survivors react at a site hit by what activists said was an air strike by forces loyal to Syria's President Bashar al-Assad in the town of Azaz, north of Aleppo, near the border with Turkey In pictures: Syria conflict Syria crisis Residents queue as they wait to receive food aid distributed by the UNRWA at the Palestinian refugee camp of Yarmouk, south of Damascus In pictures: Syria conflict Syria crisis Belongings of Syrian rebels inside a chapel at Crac des Chevaliers, the world's best preserved medieval Crusader castle in Syria. The village was destroyed in fighting between the government and rebel forces while the castle, listed as a UNESCO world heritage site, also has been damaged over the past two years In pictures: Syria conflict Syria crisis Hosen Sabah, a 16-year-old student is comforted by his mother at a hospital in Damascus. Nosen was wounded by a mortar outside his school, while 14 other students were killed and over 80 wounded In pictures: Syria conflict Syria crisis A Free Syrian Army fighter works on a locally made launcher before firing it towards forces loyal to Syria's President Bashar Al-Assad in Mork town In pictures: Syria conflict Syria crisis Syrian policemen and citizens inspecting the site of a car bomb at the entrance of Moadhamiyet al-Sham neighborhood in rural Damascus. According to Syria's Arab News Agency (SANA), a car bomb explosion has gone off in the countryside of Damascus and initial information say there are casualties, where a car rigged with explosions was remotely detonated at the entrance of Moadhamiyet al-Sham neighborhood in rural Damascus during engineering units it was trying to dismantled it In pictures: Syria conflict Syria crisis Opposition fighters carrying a rocket launcher during clashes against government forces in the Sheikh Lutfi area, west of the airport in the northern Syrian city of Aleppo In pictures: Syria conflict Syria crisis A Syrian man helps a woman to make her way through debris following reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo In pictures: Syria conflict Syria crisis A Syrian man reacts as he carries the body of injured boy following reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo. According to the Syrian Observatory for Human Rights, at least 33 civilians were killed in the attack In pictures: Syria conflict Syria crisis Syrian rescue workers carry the body of a woman following reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo In pictures: Syria conflict Syria crisis A Syrian woman walks past the burning wreckage of a car following reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo In pictures: Syria conflict Syria crisis A man and two children run to a safer place following reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo In pictures: Syria conflict Syria crisis A man holds an injured child after, according to activists, two barrel bombs were thrown by forces loyal to Syria's president Bashar Al-Assad in Hullok neighbourhood of Aleppo In pictures: Syria conflict Syria crisis An injured man talks on a walkie-talkie after, according to activists, two barrel bombs were thrown by forces loyal to Syria's president Bashar Al-Assad in Hellok neighbourhood of Aleppo In pictures: Syria conflict Syria crisis A man walks inside a mosque damaged by, according to activists, a barrel bomb thrown by forces loyal to Syria's president Bashar Al-Assad in Old Aleppo In pictures: Syria conflict Syria crisis Syrians gather at the site of reported air strikes by government forces in the Halak neighbourhood in northeastern Aleppo In pictures: Syria conflict Syria crisis Rebel fighters carry their weapons as they run to avoid snipers loyal to Syria's President Bashar al-Assad in the town of Morek in Hama province

Guards were called and ordered that the “kuffir” be punished. Rayan was thrown down the stairs, his head bouncing on the steps. Then the vicious ritual began: he was strapped to a bed and whipped with a length of cable. Then came the “aeroplane”, more beating. “It went on and on, but it was probably about two hours,” he said. “I tried to shut my mind, but the pain gets through; when I thought it was over, I realised they had other plans for me.”

Rayan was placed inside a tyre and a stick was used to twist his legs. “This was worse than anything before, and I began to pass [out]. As I was fading away I could hear one of them complaining that I was fainting too soon.”

He was awakened with water thrown over him, and then driven back to Aleppo in a van, his face forced down on the floor with a boot on his head. He was produced before a sharia court. But if al-Nusra had expected a swift sentence of judicial killing they were disappointed: fighters from moderate rebel militias were there, having heard what had happened.

When al-Nusra officials accused Rayan of inventing his torture account, he took off his shirt to show the marks of whipping on his body, and then his trousers to reveal horrific injuries to his legs. “The judge was a good judge, and he said I must be freed immediately. That shows there are still people who will stand up to extremists – it is something we can build on,” he insisted.