The 50th anniversary in July of the Sexual Offences Act 1967 will be marked by celebratory events, from Queer British Art at the Tate to the BBC’s Gay Britannia season. I feel ambivalent about the celebrations: 1967 was progress, but the criminalisation of homosexuality in the UK did not in fact end until 2013. The 1967 act was just a start. It was the first gay law reform since 1533, when anal sex was made a crime during Henry VIII’s reign; all other sexual acts between men were outlawed in the Victorian era, in 1885.

My new research reveals that an estimated 15,000-plus gay men were convicted in the decades that followed the 1967 liberalisation. Not only was homosexuality only partly decriminalised by the 1967 act, but the remaining anti-gay laws were policed more aggressively than before by a state that opposed gay acceptance and equality. In total, from 1885 and 2013, nearly 100,000 men were arrested for same-sex acts.

The 1967 legislation repealed the maximum penalty of life imprisonment for anal sex. But it still discriminated. The age of consent was set at 21 for sex between men, compared with 16 for sex between men and women; a decision that pandered to the homophobic notion that young men are seduced and corrupted by older men. The punishment for a man over 21 having non-anal sex with a man aged 16-21 was increased from two to five years.

Gay sex remained prosecutable unless it took place in strict privacy, which meant in a person’s own home, behind locked doors and windows, with the curtains drawn and with no other person present in any part of the house. It continued to be a crime if more than two men had sex together or if they were filmed or photographed having sex by another person. Seven men in Bolton were convicted of these offences and two were given suspended jail terms – in 1998.

The 1967 reform applied to only England and Wales, not being extended to Scotland until 1980 and to Northern Ireland until 1982. It did not include the armed forces or merchant navy, where sex between men remained a criminal offence. Gay military personnel and merchant seamen could still be jailed until 1994, for behaviour that was no longer a crime between gay civilians. Legislation authorising the sacking of seafarers for homosexual acts on UK merchant ships was repealed only last month.

Centuries-old anti-gay laws remained on the statute book long after 1967 as “unnatural offences”. The two main gay crimes continued to be anal sex, known in law as buggery; and gross indecency, which was any sexual contact between men including mere touching and kissing.There was also the offence of procuring – the inviting or facilitating of gay sex. The law against soliciting and importuning criminalised men chatting up men or loitering in public places with homosexual intent, even if no sexual act took place.

Men were convicted under this law, before and after 1967, for merely smiling and winking at other men in the street. There were also arrests under ancient legislation against indecency, such as the Town Police Clauses Act 1847 and the Ecclesiastical Courts Jurisdiction Act 1860.

There were police stake-outs in parks and toilets, sometimes using ‘pretty police' as bait

The 1967 decriminalisation meant that homophobic laws were not enforced in some circumstances. But many aspects of gay male life remained criminal. In fact, the repression grew much worse.

There were police stake-outs in parks and toilets, sometimes using “pretty police” as bait to lure gay men to commit sex offences. Gay saunas were raided. “Disorderly house” charges were pressed against gay clubs that allowed same-sex couples to dance cheek to cheek. Gay and bisexual men, and some lesbians, continued to be arrested until the 1990s for public displays of affection, such as kissing and cuddling, under public order and breach of the peace laws.

In 1966, the year before partial decriminalisation, some 420 men were convicted of gross indecency. But by 1974, my research shows, the annual number of convictions had soared by more than 300% to 1,711 in that year.

Homophobic discrimination in housing, employment and the provision of goods and services remained lawful by default,` with no legal protection against it until between 2003 and 2007. People were denied employment or sacked from their jobs because of their sexual orientation and gender identity. Others were refused rented accommodation or evicted from it. Some were turned away from pubs and restaurants. Gay fathers and lesbian mothers lost custody of their children in divorce cases. They had no redress in law.

In the 1980s, the Conservative government’s “family values” campaign whipped up hysterical levels of homophobia, aided by the moral panic over HIV/Aids. At the 1987 Conservative party conference Margaret Thatcher used her keynote speech to attack the notion that people had a right to be gay.

Coinciding with this intolerant atmosphere was a massive rise in arrests of gay men for consenting behaviour. In Home Office archives I found that there were 1,718 convictions and cautions for gross indecency in 1989. The 2,022 recorded offences of gross indecency that year was almost as many as the 2,034 recorded in 1954, when male homosexuality was totally illegal.

Full reform did not happen until 36 years after 1967. The gross indecency law of 1885 had been used to convict the computer genius Alan Turing in 1952 and, before him, to jail the playwright Oscar Wilde in 1895. Together with the criminalisation of anal sex, it was finally repealed by the Sexual Offences Act 2003. As a result, for the first time in 470 years, England and Wales had a criminal code that did not penalise gay sexuality. In Northern Ireland, the ban on anal sex was not finally repealed until 2008. Scotland’s anti-gay laws were repealed in 2009 but, in the case of sodomy, did not take effect until 2013. It seems scarcely credible, but gay sex ceased to be a crime in the UK only four years ago.