In the streets around Abdel Munim Riyad square the atmosphere had changed. The air which had held a carnival-like vibe was now thick with teargas. Thousands of people were running out of nearby Tahrir Square and towards me. Several hundred regrouped; a few dozen protesters set about attacking an abandoned police truck, eventually tipping it over and setting it ablaze. Through the smoke, lines of riot police could be seen charging towards us from the south.

Along with nearby protesters I fled down the street before stopping at what appeared to be a safe distance. A few ordinarily dressed young men were running in my direction. Two came towards me and threw out punches, sending me to the ground. I was hauled back up by the scruff of the neck and dragged towards the advancing police lines.

My captors were burly and wore leather jackets – up close I could see they were amin dowla, plainclothes officers from Egypt's notorious state security service. All attempts I made to tell them in Arabic and English that I was an international journalist were met with more punches and slaps; around me I could make out other isolated protesters receiving the same brutal treatment and choking from the teargas.

We were hustled towards a security office on the edge of the square. As I approached the doorway of the building other plainclothes security officers milling around took flying kicks and punches at me, pushing me to the floor on several occasions only to drag me back up and hit me again. I spotted a high-ranking uniformed officer, and shouted at him that I was a British journalist. He responded by walking over and punching me twice. "Fuck you and fuck Britain," he yelled in Arabic.

One by one we were thrown through the doorway, where a gauntlet of officers with sticks and clubs awaited us. We queued up to run through the blows and into a dank, narrow corridor where we were pushed up against the wall. Our mobiles and wallets were removed. Officers stalked up and down, barking at us to keep staring at the wall. Terrified of incurring more beatings, most of my fellow detainees – almost exclusively young men in their 20s and 30s, some still clutching dishevelled Egyptian flags from the protest – remained silent, though some muttered Qur'anic verses and others were shaking with sobs.

We were ordered to sit down. Later a senior officer began dragging people to their feet again, sending them back out through the gauntlet and into the night, where we were immediately jumped on by more police officers – this time with riot shields – and shepherded into a waiting green truck belonging to Egypt's central security forces. A policeman pushed my head against the doorframe as I entered.

Inside dozens were already crammed in and crouching in the darkness. Some had heard the officers count us as we boarded; our number stood at 44, all packed into a space barely any bigger than the back of a Transit van. A heavy metal door swung shut behind us.

As the truck began to move, brief flashes of orange streetlight streamed through the thick metal grates on each side. With no windows, it was our only source of illumination. Each glimmer revealed bruised and bloodied faces; sandwiched in so tightly the temperature soared, and people fainted. Fragments of conversation drifted through the truck.

"The police attacked us to get us out of the square; they didn't care who you were, they just attacked everybody," a lawyer standing next to me, Ahmed Mamdouh, said breathlessly. "They … hit our heads and hurt some people. There are some people bleeding, we don't know where they're taking us. I want to send a message to my wife; I'm not afraid but she will be so scared, this is my first protest and she told me not to come here today."

Despite the conditions the protesters held together; those who collapsed were helped to their feet, messages of support were whispered and then yelled from one end of our metallic jail to another, and the few mobiles that had been hidden from police were passed around so that loved ones could be called.

"As I was being dragged in, a police general said to me: 'Do you think you can change the world? You can't! Do you think you are a hero? You are not'," confided Mamdouh.

"What you see here – this brutality and torture – this is why we were protesting today," added another voice close by in the gloom.

Speculation was rife about where we were heading. The truck veered wildly round corners, sending us flying to one side, and regularly came to an emergency stop, throwing everyone forwards. "They treat us like we're not Egyptians, like we are their enemy, just because we are fighting for jobs," said Mamdouh. I asked him what it felt like to be considered an enemy by your own government. "I feel like they are my enemies too," he replied.

At several points the truck roared to a stop and the single door opened, revealing armed policemen on the other side. They called out the name of one of the protesters, "Nour", the son of Ayman Nour, a prominent political dissident who challenged Hosni Mubarak for the presidency in 2005 and was thrown in jail for his troubles.

Nour became a cause celebre among international politicians and pressure groups; since his release from prison security forces have tried to avoid attacking him or his family directly, conscious of the negative publicity that would inevitably follow.

His son, a respected political activist in his own right, had been caught in the police sweep and was in the back of the truck with us – now the policemen were demanding he come forward, as they had orders for his release.

"No, I'm staying," said Nour simply, over and over again and to applause from the rest of the inmates. I made my way through the throng and asked him why he wasn't taking the chance to get out. "Because either I leave with everyone else or I stay with everyone else; it would be cowardice to do anything else," he responded. "That's just the way I was raised."

After several meandering circles which seemed to take us out further and further into the desert fringes of the city, the truck finally came to a halt. We had been trapped inside for so long that the heat was unbearable; more people had fainted, and one man had collapsed on the floor, struggling for breath.

By the light of the few mobile phones, protesters tore his shirt open and tried to steady his breathing; one demonstrator had medical experience and warned that the man was entering a diabetic coma. A huge cry went up in the truck as protesters thumped the sides and bellowed through the grates: "Help, a man is dying." There was no response.

After some time a commotion could be heard outside; fighting appeared to be breaking out between police and others, whom we couldn't make out.

At one point the truck began to rock alarmingly from side to side while someone began banging the metal exterior, sending out huge metallic clangs. We could make out that a struggle was taking place over the opening of the door; none of the protesters had any idea what lay on the other side, but all resolved to charge at it when the door swung open. Eventually it did, to reveal a police officer who began to grab inmates and haul them out, beating them as they went. A cry went up and we surged forward, sending the policeman flying; the diabetic man was then carried out carefully before the rest of us spilled on to the streets.

Later it emerged that we had won our freedom through the efforts of Nour's parents, Ayman and his former wife Gamila Ismail. The father, who was also on the demonstration, had got wind of his son's arrest and apparently followed his captors and fought with officers for our release. Shorn of money and phones and stranded several miles into the desert, the protesters began a long trudge back towards Cairo, hailing down cars on the way.

The diabetic patient was swiftly put in a vehicle and taken to hospital; I have been unable to find out his condition.