Eighty years ago this May, one of the world's greatest pioneering sexologists and gay rights advocates died in exile with little acclaim or mourning, a victim of the unrelenting tide of Nazi persecution.

Dr Magnus Hirschfeld was a trail-blazing genius who advanced the understanding of human sexuality and the advocacy of lesbian, gay, bisexual, transgender and intersex (LGBTI) human rights at a time when it was deeply unpopular to do so. That took courage – and determination.

While Oscar Wilde was being tormented in Reading Gaol, Hirschfeld launched the world's first gay rights organisation in Berlin. Whereas Wilde merely lamented the persecution of LGBTI people, Hirschfeld organised to fight it.

His Scientific Humanitarian Committee, founded in Germany in 1897, pioneered the struggle for homosexual emancipation. A similar movement did not emerge in Britain until the 1960s, over half a century later. He truly was a man ahead of his time.

Hirschfeld was born into a conservative Jewish family in what was then Prussia in 1868. During his childhood, he developed a curiosity and fascination with sex. Against the conventions of his era and the moralism of his elders, even as a young boy he viewed sexuality as something entirely natural and wholesome.

At medical school, he was traumatised by a lecture on "sexual degeneracy", where a gay man –who had been incarcerated in an asylum for 30 years because of his homosexuality – was paraded naked before the students like a laboratory animal. Hirschfeld was the only student revolted by such mistreatment. All the others, even his best friend, viewed it as normal and justified.

Further trauma ensued when, soon after setting up himself as a doctor in Berlin in 1893, he was waylaid outside his apartment at night by a soldier who was deeply disturbed by his homosexuality. Hirschfeld resisted the soldier's pleading for a consultation there and then, telling him to come to his surgery the next day. Overnight, however, the soldier committed suicide.

Guilt leads to action

Hirschfeld's terrible guilt and remorse motivated him to begin studying homosexuality and, eventually, to write a pamphlet calling for the decriminalisation of gay sex, which was then outlawed under Paragraph 175 of the German penal code.

When his family advised him to study something more worthy and respectable, such as cholera, arguing research into homosexuality would not bring him any acclaim or joy, Hirschfeld riposted: "What are you saying: that cholera brings you more joy than sexuality?"

As his pro-gay reputation spread, more and more men who were unhappy with their homosexuality came to him as patients. Hirschfeld's prescription? Lots of gay parties and plenty of boyfriends.

One of Hirschfeld's biggest problems was hostility from other gays and lesbians. They mostly accepted their second-class legal status. Many did not like him rocking the boat. He was seen as a troublemaker. They refused to co-operate with his sex surveys and law reform campaigns.

Realising his lone efforts were not enough, in 1897 Hirschfeld founded the Scientific Humanitarian Committee (SHC). Its strategy was to promote research and education on all sexual matters; in particular to debunk homophobic prejudice and to present a rational case for the decriminalisation of homosexuality.

The 1890s equivalent of UK gay lobby group Stonewall, SHC's motto was "Justice through science". Some of its more radical supporters adapted the battle cry of the French Revolution, demanding: "Liberte, Fraternite, Egalite, Homosexualite!"

As well as having to contend with the complacency and disparagement of other gay people, Hirschfeld was also attacked from the left by militant OutRage!-style campaigners led by Adolf Brand. Advocating direct action and the outing of homophobes, Brand denounced Hirschfeld's "queeny committee" as a talking shop of respectable, middle-class homosexualists.

Much as I admire Brand's defiant, assertive gay activism, his criticism of the SHC was a bit unfair. In those ignorant, bigoted days, to have a group like Stonewall was truly radical – almost revolutionary. This is confirmed by the way the SHC and Hirschfeld were put under police surveillance as subversives and subjected to repeated harassment.

Due to Hirschfeld's tireless campaigns, in 1898 the German parliament debated the repeal of Paragraph 175. Leading the call for its abolition was August Bebel, head of the left-wing Social Democrats (Hirschfeld was also a prominent member of the SPD). Although defeated, the debate put homosexual equality onto the mainstream political agenda for the first time.

Dens of debauchery

Undeterred by this setback, Hirschfeld decided to tackle the police, in bid to stop them enforcing the unjust anti-gay laws. He took the police commissioner of Berlin on a tour of gay bars and clubs. Instead of the dens of debauchery that he was expecting, the commissioner found LGBTI people were witty, stylish, polite and well behaved – and he enjoyed their company. "I wanted to see Sodom and Gomorrah," he complained somewhat disappointedly.

To strengthen the rational, scientific case for law reform, Hirschfeld proceeded with his medical research into the causes and nature of homosexuality, in the hope that understanding the facts would discourage prejudice and promote acceptance.

Far in advance of others, he concluded everyone is a mixture of male and female. But this perceptive true analysis led him to erroneously advance the idea that lesbian and gay people were an "intermediate sex" that was biologically predetermined at birth. In his view, male homosexuals possessed a "woman's soul trapped in a man's body".

This well-intentioned misjudgment aside, Hirschfeld was right on most other things. He can and should be forgiven.

Far in advance of others, Hirschfeld concluded that everyone is a mixture of male and female

As well as his concern for the welfare of homosexuals, he was also a strong advocate of the rights of transgender people – again, decades ahead of his time.

Good fortune shone on Hirschfeld when he was paid a fabulous sum to perform one of the world's first gender reassignment operations. The payment enabled him to establish the Institute for Sexual Science (ISS) in 1919, which predated Dr Alfred Kinsey's US sex research institute by nearly three decades.

As well as its research role, the institute promoted sex education, contraception, marriage guidance counselling, advice for gay and transgender people, the treatment and prevention of sexually transmitted diseases, gay law reform and women's rights. It saw over 20,000 people a year.

These were novel ideas at the time and Hirschfeld's fame and notoriety spread worldwide. When told American newspapers were hailing him "the Einstein of sex", he wittily replied that he would feel much happier if they called Einstein "the Hirschfeld of physics".

Nazis opposed to Hirschfeld's work

But his work bought him into conflict with the Nazis. They ranted against his "perversions" –attacking his public meetings and beating up him and his lover and assistant, Karl Giese.

While away in the US lecturing in 1933, Nazi stormtroopers attacked and ransacked the ISS destroying its priceless research archives. The vast library was burned in the great bonfire of "enemy books".

The newsreel footage of these burning books features in almost every documentary about the Nazis and in all the main history books. But it is rarely acknowledged that it was Hirschfeld's institute and the headquarters of his German gay rights movement that were the main targets and victims of the stormtroopers' wrath.

The Nazis also seized the institute's huge list of client names and addresses. These were used by the Gestapo to compile its notorious "pink lists", which identified homosexuals and led to their arrest and deportation to concentration camps.

With the Nazis publicly denouncing Hirschfeld as one of the country's leading "Jewish criminals", which was effectively a death sentence, friends advised him not to return to Germany. He went to the south of France instead, where he died suddenly of a stroke in 1935. Giese committed suicide in 1938, while on the run from the Nazis. Both died sad, lonely deaths, unbefitting their enormous humanitarian contributions.

It took many decades for Hirschfeld's life and work to be properly documented and for him to receive the social acclaim he so richly deserved.

His extraordinary endeavours are thankfully now well documented in the film The Einstein Of Sex (directed by Rosa von Praunheim and released in 1999), and in the biography Magnus Hirschfeld by Charlotte Wolff, published 1986. They chart his political campaigns, sexual research and the myriad ups and down of his own less than joyful personal life.

As with so many other human rights campaigners, Hirschfeld often sacrificed his own happiness and comfort for the love and welfare of others. A true pioneer and hero of the struggle for sexual human rights, and queer emancipation.

For more information about the Peter Tatchell Foundation's human rights work, to receive our email bulletins or to make a donation: www.PeterTatchellFoundation.org