Every day, Ahmed Mourad quietly seethed as he peered through a lens darkly at Hosni Mubarak and reflected on the misery that his boss – the man he knew as "Mr President" – was inflicting on Egypt's 80 million people.

After five years as the personal photographer to Mubarak, recording everything from world leaders' visits to quotidian family gatherings, Mourad, then 29, had seen enough and was "ready to explode", as he puts it now.

That was in 2007, four years before the inspirational uprising that forced Mubarak out in February this year, after 30 years of dictatorship. At the time, thousands of workers were on strike and journalists were protesting about being silenced, but Tahrir Square was quiet. If you did not want to go to jail, with the attendant risk of being tortured, there was little outlet for political protest. So, in the evenings, Mourad vented his anger by writing.

The result, later that year, was Vertigo, a racy, blood-spattered thriller that exposes the greedy, seedy, corrupt businessmen and politicians who get rich by exploiting the poor. It was a story that resonated in Egypt and the book – which Mourad says was never meant for publication – became a bestseller. Now, after its translation into English, he has talked for the first time about the emotions that inspired him to write it.

"I was ready to explode because I had been living a dual life for five years, like Dr Jekyll and Mr Hyde," says the dapper, quietly spoken Mourad. "During the day, I spent hours working with Hosni Mubarak – a man who had been burying the dreams of Egyptians for three decades – and at night I was with my friends, who were cursing him and wishing he would disappear. What was really making me angry was that I knew the Egyptian people were destined to live better and he was the reason why that wasn't happening."

So was Mourad in fear for his job – or, indeed, his life – when Vertigo appeared? He does not answer the question directly. "I didn't think it would be published, but I would never have forgiven myself if I hadn't written down what I was thinking, if I hadn't joined the revolution," he says. "I would have regretted my silence."

So he viewed his writing as a revolutionary act? "Yes – and it was a duty to my country: to shout and scream and make people wake up and see the truth." But when he had written Vertigo, he did not think it was good enough. "I thought it was crap. It was my wife, Sherine, who encouraged me to try to have it published."

There was another problem: it was a thriller, a genre largely unknown in the Arab world. But Mohamed Hashem, the brave owner of Merit Publishing in Cairo, which specialises in experimental literature, said he liked it, described it as "cinematic" and agreed to publish it. As a film-maker as well as a photographer, Mourad was more than happy with the description: Vertigo has a self-consciously Hitchcockian title and the book is dotted with allusions to Hollywood.

If only Mubarak and the goons who sustained his tyranny had read more fiction they might have realised there was a nascent revolutionary in their midst. "The regime didn't read the novel, they didn't like reading at all. I think that was my luck," says Mourad, now 33.

The intelligence agents – the Mukhabarat – would not have needed to look far for clues. Vertigo's protagonist is a bespectacled young photographer called Ahmed Kamal, born on Valentine's Day, the son of a photographer, who inherits his job from his father. Ahmed Mourad, whose birthday is 14 February, is the son of a photographer who secured his job in the presidential palace through a friend of his father. And, yes, he wears glasses.

The book begins with Ahmed witnessing by chance, and surreptitiously photographing, a massacre in a revolving restaurant – Bar Vertigo – a haunt of the rich and powerful in downtown Cairo, high above the Nile. The central victims are two corrupt business tycoons with friends in high places. The plot turns on Ahmed's attempt to persuade an apparently fearless editor of an "eye-catchingly vulgar" tabloid to publish the pictures. But the editor of the ironically named Freedom turns out to be a hypocrite. He is as corrupt as the others – and also has a predilection for underage girls.

Vertigo is peppered with barbed comments that might have upset an oversensitive, or paranoid, member of the regime. "Haven't you heard about what happens in state security?" Ahmed's best friend, Omar, asks him. "If they arrested Hitler himself they'd hang him up and make him confess that he belonged to a terrorist cell in Imbaba [a district of Cairo] that wanted to overthrow the government."

Later, referring to the rich and powerful, the fictional Ahmed says: "So what if I want revenge on these people? They're hurting me now, but they've been hurting this country for a very long time. If my loathing of them makes me take revenge on behalf of others, where's the problem? People don't have the time or the wherewithal to wake up and go after what they deserve or to fight for it. People are worried about their next meal."

In Vertigo, as in real life, some of the good guys are killed – either deliberately or in the crossfire – but the bad guys get their comeuppance. Hosni Mubarak, now 83, is on trial in Cairo charged with complicity in the killing of more than 800 protesters during the 18-day uprising. The former despot and his two sons, Alaa and Gamal, also face corruption charges. The sons have allegedly secreted £215m in Swiss bank accounts. The trial has been adjourned until 28 December. Mubarak could face the death penalty if convicted.

Did Mourad view Mubarak as evil? "I do not believe in the idea of absolute evil. He was a person who tried to be good, but failed and lost his reputation – and the respect of his people." Mubarak had never mistreated him. "He was not aggressive with me. In general he was gentle, but many people say he was aggressive with his servants and his advisers."

But if Mourad was so upset about the repression, why did he not walk out? "Me quitting would not have helped my country," he says. "On the contrary, I profited from having a bird's eye view of what was going on – and it pushed me into writing."

His friends, who demonstrated in Tahrir Square every day, had not urged him to resign. "No, finding a job in Egypt is very hard and they did not consider me to be a traitor," he says. Finally, on 11 February, after Mubarak departed, he was able to join his friends in the joyful celebration in the square as they shouted: "Egypt is free."

Nine months later Mourad is still in the palace, waiting for a new president to photograph. Like many Egyptians, he fears Mubarak's successor will be a similar figure. Certainly, the increasingly repressive military junta that now rules the country does nothing to inspire confidence. But in theory the long and rutted road to democracy has begun.

At the end of the month, the people will vote in a bewilderingly complicated parliamentary election, but there may not be a presidential vote until 2013. Even then, as those who lived under communism in eastern Europe testify, dictatorship is psychologically difficult to shake off. "I think the regime is inside all of us, not only Mubarak, and people are still in shock," says Mourad. "I think my fears will calm down if and when a civilian takes power."

For his fellow countrymen, whose dreams were buried for 30 years, he longs for an Egypt "where the people have dignity and a decent life". And for his daughters Fatema, aged five, and Roqaya, 18 months, he hopes for freedom – throughout their lives.

Mourad has already written a second, and bloodier, thriller, Diamond Dust, published in Arabic. As for writing about the bloody revolution, he says it is too early. "I will probably do it in about five years, when things have settled down and I have worked out what I think."

Vertigo, by Ahmed Mourad, is published by Bloomsbury Qatar Foundation