In March 2013, Free Syrian Army fighters, alongside the al-Qaida-linked militia Jabhat al-Nusra, liberated Raqqa, a city in Syria’s east. Statues of Assad were attacked, detainees were set free, a hip-hop concert was held. Activists hotly debated the shape of the democracy to come. They set up a local council; Nusra set up a Sharia court. Then Isis, or Daesh, an Iraqi-led group, split from Nusra. It was contained for a while, until the Free Army in Raqqa was weakened, battered by airstrikes and “busy fighting the regime elsewhere”.

In January 2014, Daesh captured the city. “Snatching it away from the revolutionaries who had sacrificed everything to liberate it,” the jihadists immediately established rule by fear. Some people fled, some submitted and some resisted as best they could. The pseudonymous author of The Raqqa Diaries – translated by Nader Ibrahim – risked his life to break Isis’s communication siege; his group, al-Sharqiya 24, made contact with the BBC correspondent Mike Thomson, and a bare-bones version of this book was read on Radio 4’s Today programme. It is as powerful and fast-paced as a thriller, but this is brutal non-fiction, plainly and urgently told.

Samer describes the people of Raqqa – a conservative but deeply civilised city, with a history stretching back to the Babylonian era – as “humble” and friendly. Under Assad, the author’s father was detained for raising the issue of corruption. The family was forced to exchange its wealth for his freedom. Samer describes how he himself was detained in 2011 and tortured for attending anti-regime protests. He tells of fleeing to liberated territory, then returning when the regime retreats from the city.

Dress codes and protection rackets … veiled women sit on a bench in Raqqa. Photograph: Reuters

The Isis takeover brings with it a surreal blend of Ba’athist totalitarianism and Salafi-jihadist Islamism. The new rulers impose dress codes on both sexes, ban smoking and TVs, and implement compulsory prayers, evening classes and sharia courses, where the people are told “we are heretics and need to be reintroduced to Islam”. Isis stones women, throws gay men off roofs, and brutalises and conscripts children.

For executions, they gather a crowd “as if they are about to stage a play”. “Apostates” – retired regime soldiers, revolutionaries, citizen journalists – are beheaded by sword in the squares and on roundabouts. The heads are hung on lamp posts and mounted on park fences. Samer curses loudly when he discovers his own neighbour’s decapitation, and is arrested and lashed for it. This is his first brush with Isis. Next, his girlfriend is forcibly married to a Daesh fighter.

The air war rages – American strikes on Isis buildings, Russian strikes on marketplaces. Samer’s home is hit, his father killed. Isis, in response, escalates the repression. “Every time they feel threatened, they lash out at us.” Every activist is a potential target. Everybody suffers from rocketing prices. While half-starved residents burn books in order to boil water, handsomely waged jihadis impose a tax system indistinguishable from a protection racket.

A man who has memorised the entire Qur’an criticises an Isis sermon and is executed as 'an enemy of Islam and Allah'

Samer resists by writing. Because the internet cafes are staffed by spies, he sends encrypted text through two intermediaries to the outside world. But the net soon tightens around him. His friend Anas is crucified. Then a man called Khalid, who has memorised the entire Qur’an, criticises an Isis sermon and is executed too, as “an enemy of Islam and Allah”.

“Islam is the most precious thing we have,” Samer writes, “a glimpse of light in these very dark times.” Raqqa’s Muslims keenly resent Daesh’s abuse of their religion “to cover up their criminality”. Only a very few become true believers, and these are misfits such as Waleed, a mentally disturbed loner who executes his mother for disloyalty.

Samer eventually escapes, in stages, dodging checkpoints throughout the depopulated north. Those who accompany him have their own terrible stories. He ends up in a camp still inside Syria, short of food and medicine, circled by warplanes, and surrounded by “people like me ... thousands who have fled their homes running from either Daesh or Assad’s regime”.

Using Islam ‘to cover up their criminality’ … Isis fighters parade through Raqqa. Photograph: Uncredited/AP

By way of conclusion, he expresses Syrians’ continued hopes for change, but also the fear, disappointment and growing despair of a people who want only to rule themselves, yet are constantly overruled. What, after all, will replace Isis? The return of the Assad tyranny – which “feeds on darkness and grows ever stronger” – is not a solution. Like many Syrians, Samer believes there is a “special understanding between the regime and Daesh, like that between father and son”. Ibn Khaldun, the 14th-century historian, is quoted at the start: “Tyrants bring invaders.” At the same time, Samer is anxious that liberation by the US-backed and Kurdish-dominated Syrian Democratic Forces – the army currently approaching Raqqa – would “simply be passing from one terrible occupation to another”.

How do those still inside survive the situation? Not by living in the present. A wise man gives Samer this advice: “Imagine you’re walking on a rope between two mountains. The present is the ground below. Focus only on crossing to the other mountain.”

• The Raqqa Diaries: Escape from Islamic State is published by Hutchinson. To order a copy for £8.49 (RRP £9.99) go to bookshop.theguardian.com or call 0330 333 6846. Free UK p&p over £10, online orders only. Phone orders min p&p of £1.99.