Tomorrow marks the 50-year anniversary of the publication of the Wolfenden report on homosexual offences and prostitution. It emerged at a time of great sexual ignorance. In the 1950s there were no manuals for the young, and we had to do our best with baffling encyclopaedia entries. Our elders wanted to re-establish the imagined values of Britain's lost empire. They were full of warnings about VD and how Rome fell because of its tolerance of homosexuality. So as well as the disastrous Suez campaign of 1956, there was a tripling of prosecutions for homosexual offences after 1945.

The police frequently obtained their convictions by offering not to charge a man in return for the names of his partners, until they had a whole "ring" to bring to court. Suicides before these mass trials were common, and those found guilty usually received long prison sentences. As a result queers, though as numerous as today, tried to be largely invisible, conducting furtive lives under the constant threat of blackmail, exposure, prison and disgrace.

But when the recently knighted John Gielgud was caught cottaging in London, and Lord Montagu was accused of assaulting boy scouts in Hampshire, homosexuality suddenly became visible. Gielgud was fined a token £10, but was, to the dismay of the authorities, cheered when he next appeared on stage. The case against Montagu was dismissed when the police were shown to have altered his passport in their eagerness to get him.

Furious at this public disgrace, and probably encouraged by the home secretary, Sir David Maxwell Fyfe, the police obtained confessions from two young airmen in return for immunity from prosecution and arrested Montagu again, along with two others. Their houses were searched without warrants. When all three were sent to jail, the ordinary public showed what it thought of this vindictiveness by cheering Montagu and his friends and booing and spitting on the airmen.

At that time, according to Dr Alfred Kinsey, who had recently published his report on male sexuality, the West End of London had more street-walkers than Havana, and the government was wondering what to do. A royal commission was proposed into prostitution, and liberals in the Home Office suggested that it should investigate homosexuality as well.

Maxwell Fyfe, who may have thought it an opportunity to tighten the law, took the idea to the cabinet, where the one well-known queer kept his mouth discreetly shut. Churchill, near the end of his career, wanted to sweep the subject under the carpet by forbidding the reporting of details of homosexual cases. This proved impracticable, but a Home Office committee didn't have to publish all its evidence like a royal commission. So the Wolfenden committee came into being, under Jack Wolfenden, the vice-chancellor of Reading University. His own son, though he probably didn't then know it, was gay.

The committee met for three years before deciding, with one dissenting opinion (an adamant procurator fiscal), that homosexual behaviour between consenting adults in private should no longer be a criminal offence. Beyond that it was scared to go: adulthood should remain at 21 and buggery should stay illegal. Even this was far too shocking for a Conservative government, and it was 10 years before the law was changed under the Labour home secretary Roy Jenkins.

By then the very existence of the report had changed the climate of opinion. Homosexuality was widely discussed and ignorance no longer possible. The change, once made, seemed obviously right.

Though governments continued to be craven, later liberalisations have been accepted almost without comment. Now young people are amazed that homosexuality was ever illegal at all.

For us older people, the transformation of life has been scarcely credible. The producer of Consenting Adults (my television play about Jack Wolfenden and his son Jeremy), born in 1956, says he's astonished we had to wait so long for civil partnerships to be legal. I, who grew up when gayness seemed like a life sentence to secrecy and shame, am amazed it ever happened at all.

When my partner and I came out of the register office arm in arm into the busy street I wondered, as I've wondered all my life, what people would think about us. But no one even looked up. And for that we can thank Jack Wolfenden, who - despite his distress at his son's sexuality - laid out the arguments for change in an objective and ultimately irresistible way.

Of course there is still prejudice - in the macho worlds of the City and football, and especially in schools. With puberty coming earlier, gays are found out in their early teens. Adolescent boys are conformist and bullying is a real problem. But most of us can forget our difference and get on with our lives as ordinary people, not a frightened minority defined solely by our sexuality.

· Julian Mitchell is the author of the play Consenting Adults, which is broadcast on BBC4 at 9pm on Wednesday.

comment@theguardian.com