Media playback is unsupported on your device Media caption Memoir reveals hidden life of Hamid Zaher

Hamid Zaher is a young Afghan pharmacist, now living in Toronto in Canada. He has defied Afghan tradition by writing a searingly honest memoir about what it was like to be a gay man in Afghanistan.

The book has never been published in his home country, where homosexuality is a criminal offence punishable by death.

Hamid Zaher says that he's always known that he was different.

Growing up in village in the Afghan countryside in the early 1980s, he describes his childhood as a bitterly unhappy time when he was forced to hide his true feelings.

"When I was growing up I was sometimes attracted to men," Hamid told the BBC. "But I didn't really understand my sexual orientation until I was 15 years old."

Hamid says that as a child he always felt more comfortable playing with the girls in his village.

"I wanted to pretend that I wasn't gay," he says. "But it wasn't true, I was living behind a mask."

Eventually what Hamid calls his "feminine traits" began to attract negative comments from friends and relatives.

Marriage pressure

"They started calling me Hamida, the feminine form of my name and 'Izak', a colloquial term for someone who is neither male nor female," he says.

Throughout his student years, Hamid kept quiet about his sexual orientation, fearing not just the stigma but the very real threat that he could be prosecuted and even sentenced to death for being a gay man.

From "It is your enemy who is dock-tailed" by Hamid Zaher Whenever I danced in parties, all men, young and old, would laugh at me and say, "Wow ! he dances exactly like a girl !" Their laughter would sadden me. I would go and sit in a corner and would no longer dance… I lost my spirit and confidence day by day. I became a coward and was isolated.

Things came to a head when he was 25 and his mother tried to pressure him into getting married. Unwilling to go through with it, he left the country, going first to Pakistan, then to Iran and Turkey, before eventually settling permanently in Canada in 2008.

"It's not possible to be openly gay in Afghanistan," he added. "I would have been killed by my relatives, let alone the government."

Hamid's book, entitled "It is your enemy who is dock-tailed", is an impassioned and defiant attack on the conservative traditions and prejudices which he says made it impossible for him to carry on living in his home country.

As he writes in his book, the title is an oblique reference to an old Arabic expression which refers to a man without a son as being "dock-tailed" or without any descendants.

"I wrote the book because our rights have been denied," he says. "I don't want other generations of my country to be afraid of their sexualities."

Wall of silence

Although segregation between the sexes means that homosexual activity in private is not unknown in Afghanistan, there is no publicly visible gay community whatsoever.

Professor Dawood Rawish, a sociologist from Kabul University, says it is impossible to know how many gay Afghans there are because people are just too scared to take the risk of coming out.

Image caption Hamid says living in Canada has given him the chance at a happier life

"This is a big stigma in Afghanistan," he told the BBC. "People see it as an immoral act... According to the law those involved could be punished by death."

The Persian version of Hamid's book, which was published in 2009, has been met with a wall of silence in Afghanistan.

Although it was impossible for him to distribute hard copies inside the country, Hamid made the book available online free of charge.

But such is the taboo that almost no-one wants to comment or even to acknowledge that they've read it.

Afghan human rights officials, contacted by the BBC, refused to comment on whether gay Afghans ever appeal to them for help.

"Afghanistan is a no-go area for gays," said a human rights activist who asked not be named. "Hamid's revelation is revolutionary in today's Afghanistan."

But Hamid's openness has come at a cost. His family have disowned him and he no longer has any contact with any of them.

"My brothers asked me not to publish the book," he says. "But, I didn't want to suppress my feelings any more. I wanted to be the first voice of Afghan gays."

Hamid says the estrangement from his family is a price worth paying.

"I have fulfilled a responsibility and of course living in Canada provided me with that chance. I was ready to die for it, but not to hide it anymore," he said.

"I am who I am. I am happy to be living a life I want, not what my family and the society expect me to live."