Cairo, Egypt - As Gabr sat in a seafront cafe in his hometown of Alexandria, he spoke about his past opinion of atheists. "I used to think that they should be killed," he said matter-of-factly.

Gabr - not his real name - was brought up in a moderate Muslim family before becoming a Salafi, a follower of a literalist and puritanical form of Islam. He eventually underwent a radical shift in belief to become one of those people he used to despise: an atheist, an apostate, a kafir - a group of people who feel under threat in Egypt because of their lack of belief in God.

Atheists are uncommon in Egypt, and reliable statistics on their numbers are unavailable because of the lack of research and an unwillingness to admit one's atheism. However, both atheists and religious people in Egypt agree that atheism has recently become a more prominent issue in the country.

"I never knew there were any atheists in Alexandria until 2011, after the revolution. Before the revolution, all this time, I was thinking that I am the only one here," recalled 30-year-old Gabr.

"It was very lonely. My computer was my world. Until 2011, I was just contacting foreign people and almost stopped contact with Egyptian people. You feel like you are so different, you are against everything religious people say, you can't meet them in the middle."

For a time after the 2011 uprising against former president Hosni Mubarak, there was greater freedom of expression in the country, and atheists began to be more publicly assertive. Yet at the same time, the power and influence of conservative Islam grew, with the election of Mohamed Morsi as president and Islamist parliamentary candidates' success at the ballot box.

All of them are angry, in a way that you can't imagine. They insult everything. I don't take these messages seriously. - Gabr, Egyptian athiest

'All of them are angry'

Gabr is a member of an atheist group that meets up for drinks and goes to concerts together. When the group began in 2011, it had three or four members. Now it has close to 100, including men and women, ex-Muslims and ex-Christians.

"All of them are angry, in a way that you can't imagine," he said. "They insult everything." Gabr claimed he has received threats from people on Facebook threatening to kill him with a sword. "I don't take these messages seriously," he said. "For me, it is pathetic. I see them as victims." Nevertheless, he did not want to use his real name for this article.

For atheists and those perceived to be critical of religion in Egypt, the threat of violence and persecution is real. Although atheism is not technically illegal in Egypt, its penal code criminalises "contempt of heavenly religions", desecrating religious symbols and mocking religious rites in public.

In late October it was reported that Sherif Gaber, a 20-year-old student, had been arrested after allegedly setting up a Facebook page calling for atheism. The author Karam Saber is currently appealing a five-year prison sentence after being convicted of contempt of religion and defamation in his book Where is God? And in December 2012, Albert Saber, an atheist blogger and activist, was sentenced to three years in jail after being found guilty of "defamation of religion".

'Society is the problem'

The authorities, Egyptian atheists say, are not the only danger they face. "I'm not afraid of the government, I'm afraid of the people. Society is the problem," said 28-year-old Ayman Emam.

About a year ago, Emam set up a Facebook page called "Egyptian Atheists Community" in Cairo. The group has 15 members and includes former Muslims and Christians. He described the page as an attempt to draw attention to the threats and persecution faced by atheists in Egypt, from Christians as well as Muslims.

When asked how atheists are treated, he replied: "It depends on your luck. You can be an atheist and telling people, and nothing can happen to you. Or you can be fired from work, your life can be destroyed, acts of violence can be taken against you. It depends where you are, the circle of people around you. For me, the people at work don't know. The people at school didn't know. You have to keep your opinions to yourself. It's a stressful situation."

People who have been perceived to be criticising religion have been attacked and murdered in Egypt. In 1992, the writer Farag Foda was assassinated by religious hardliners after being accused of blasphemy. The Nobel Prize-winning novelist Naguib Mahfouz was stabbed in the neck by Islamists in 1994. He survived but suffered permanent injuries.

According to the Pew Research Center, 74 percent of Egyptian Muslims want sharia, or Islamic law, to be recognised as the official law. Of those committed to sharia law, 86 percent favour the death penalty for those who leave Islam - although this is technically defined in the survey as those who join another faith.

Despite his fears, Emam said he feels the need to respond to what he sees as growing religious conservatism and intolerance in Egypt, and he insists his group is not proselytising. "What benefit does it give you as an atheist if you convert people to atheism?" he asks. "We just want people to be more tolerant to our beliefs and we want society to be more balanced."

Straining relationships

Noha Mahmoud Salem, 53, describes herself as a former "fanatic" and Salafi. She began wearing the niqab, or veil, at the age of 21. At 24, she married a conservative Muslim and they had three boys together. But around the age of 30 she began having doubts about religion, and she stopped praying.

Both Noha and her husband thought she might have a psychological problem. She went to see specialists who told her she was suffering from obsessive compulsive disorder and needed strong medication. The medication didn't seem to help, and she was still questioning her faith, so she was given stronger and more harmful drugs. She became like a zombie, she said.

"It stopped my thinking and I was afraid that some damage had been done to my brain," she recalled. "When I stopped the medication, my brain gradually recovered."

But her questioning of religion continued. Noha finally got divorced from her husband in 2007, after nearly 25 years of marriage. She does not, however, describe herself as an atheist. "It is better to say I am a 'Muslim' but 'an intellectual Muslim,'" she said, "because when I say 'I am a Muslim', people will begin to hear me. Otherwise they will be my enemies."

Yet she cannot get her three sons to listen to her. Her relationship with them is a big source of anguish. She describes them as Salafis. They treat her harshly, and warn her that she is going to hell; meanwhile, she tells them there is no hell.

"They always tell me that I am psychologically troubled," she says. A few months ago, Noha got a certificate from a psychologist in Alexandria proving that she is mentally well. What did her family say? "No, the doctor is wrong; he didn't give you the right diagnosis."

As an atheist, Gabr has struggled in his romantic life. He cannot admit his atheism to religious girls. "You have to be a hypocrite," he said. He recently met a Christian girl he liked, but when she saw from his online posts that he was an atheist, "she got mad and said 'I am not proud to know someone like you'".

Ayman Emam was harassed by the police and neighbours when he lived with his atheist girlfriend, because they were not married. It is impossible for atheists to marry, unless they pretend to be religious, as civil marriages are not possible in Egypt. Emam denies that atheism is a gateway to vice and debauchery, pointing out that there is no shortage of these among religious people. "Religion doesn't stop people from having sex and drinking alcohol," he said, "things that they enjoy".

Atheism and the uprisings

While Egyptian society has grown more religiously conservative, the uprisings have also provided some space for atheists and those critical of religion to speak out. "The psychology of the Egyptians completely changed after the [2011] revolution," said Salem. "Now they are more open - everybody wants to say something. Really, myself, I feel more courageous."

Emam is more ambivalent. Though he said he thinks the removal of Morsi may make society more liberal in terms of art and drinking alcohol, he believes that "nothing has changed regarding the general feeling towards atheists. The society is still the same."

Waves crashed soundlessly against the sea walls, drowned out by the vehicles hurtling along the corniche, as Gabr sat in a seafront bar. Couples and families strolled and took in the sea air, or sat along the harbour walls. Most of the women were wearing the hijab, or headscarf.

Like Emam, Gabr said he was ambivalent about the uprising's consequences for atheists. "It gave you more space. You can speak your mind more," he said, adding that atheists may be entitled to greater freedom of speech now that the Islamist President Mohamed Morsi has been ousted. Yet the "revolution" has not produced all the freedoms he had wished for.

A new constitution is being drafted in the wake of Morsi's ousting. A group of atheists recently called for this document to respect freedom of expression and to protect atheists. They called for the repeal of several articles, including Article Two, which states that Islam is the religion of the state and that sharia is the basis for legislation. However, it appears unlikely they will get the protections they are looking for.

Despite his misgivings, Gabr is hopeful for Egypt's future. "I like to take the French revolution as an example, because it took years," he said. "Everything didn't change at once. But something started; a process."

Follow Patrick Keddie on Twitter: @PatrickKeddie