In September 1957, when the Committee on Homosexuality and Prostitution made public its findings and recommendations, known as the Wolfenden report, I'd arrived at Indiana University to begin graduate studies. The university's Bloomington campus was then best known for the Kinsey Institute for Sex, Gender and Reproduction. Its founder and head, Dr Alfred Kinsey, the zoologist turned sexologist, had recently died.

The institute rightly claimed responsibility, through its seminal 1948 and 1953 Reports on the Sexual Behaviour of the Human Male and the Human Female, for creating the climate of opinion that led to the part of the report recommending that sexual activity between consenting males in private should no longer be a criminal offence.

A meeting was held to discuss the recommendations, about which I reported to one of my closest friends, Sir John Wolfenden's gay son, Jeremy. Somewhat naively, I believed that legislation would soon follow. But Jeremy, who after graduation from Oxford that summer had started full-time work at the Times, wrote to tell me about the hostile response of the British press and politicians. Years would pass, he opined, before anything was done. He was right.

By then, Jeremy, who was godfather to my eldest son, had drunk himself to death. He died in December 1965 while in Washington as the Daily Telegraph correspondent. For a while, rumours circulated that he was the victim of the CIA, the KGB and/or our SIS. A play by Julian Mitchell about Jeremy's life and relationship with his father, in which there's a character loosely based on me, will be broadcast on BBC4 in September.

I first met Jeremy, widely regarded as one of the most brilliant men of his generation, in 1954, a year that was a turning point in my life. During the first five months of that year, I was completing my national service as a second lieutenant in an infantry regiment in Egypt. In that world, devoid of women, homosexuality was mocked, castigated and feared. The chief topic of amused conversation in the officers' mess was the trial of Lord Montagu of Beaulieu, Michael Pitt-Rivers and journalist Peter Wildeblood for having sexual relations with two aircraftsmen who had informed on them to the RAF police to protect their skins. All three were humiliated and jailed. Little sympathy was shown them. I was deeply impressed when I read that 26-year-old Ken Tynan, recently appointed theatre critic of The Observer and a writer I much admired, had risked public obloquy by standing bail for Wildeblood.

Returning to civilian life in May, I spent four months working in a Bristol car showroom seething with prejudice of every kind: sexual, racial, political. I became aware I was living in an era of repression and that pressure from the House Un-American Activities Committee, the State Department and the FBI was being brought to bear on the Home Office of Sir David Maxwell-Fyfe, one of the worst Home Secretaries in living memory, who, to allay critics, had appointed the Wolfenden Committee that year.

There were much publicised attacks on homosexuals. American fugitives from McCarthyism were being harassed by MI5 and the Special Branch. Books from reputable publishers were prosecuted for obscenity, though in most cases they were acquitted.

My scepticism about society and my newfound libertarian attitudes were fuelled by an army friend who'd introduced me to anarchism. Going up to Oxford in October, I discovered (alongside conventional thinking, snobbery and crude prejudice) a refreshing world of intellectual freedom and social tolerance. For the first time, I met men who were openly gay, a term not used then, and a few who were straight but affected camp mannerisms to give themselves style.

What I knew about homosexuality at the age of 21 came from playground folklore, the ignorant talk of my parents' lower-middle-class circles, barrack-room chat, the News of the World and books. I knew that a good many people I admired, from Oscar Wilde and Noel Coward to WH Auden and Christopher Isherwood, were gay. But apart from rumours about schoolteachers, scoutmasters and RAF parachute instructors, I had no direct experience of homosexuals.

At Oxford, I came to enjoy the company of a good many and thought them victims of a grave injustice. From my first term, Jeremy Wolfenden became a special friend. We worked together on the student magazine Isis for two years. When he edited Isis, I wrote an article, partly occasioned by Peter Wildeblood's autobiography, on the absurdity of the laws relating to personal sexual conduct and the deformities they afflicted on us all. Jeremy encouraged me to write it as a way of directly addressing his father. For my inaugural editorial in April 1956, I nailed my libertarian colours to the mast by choosing to write about 1954 as a year of shame.

Not that this changed much. The Lord Chamberlain routinely refused to license serious plays touching on homosexuality. In 1956, there were so many American plays banned from public performance for this reason (A View From the Bridge, Tea and Sympathy, Cat on a Hot Tin Roof), that the Comedy Theatre in the West End was turned into a club so they could be presented. It took courage in that moral climate for a star like Dirk Bogarde - gay, but going to his grave without coming out - to appear in the 1961 thriller Victim (pictured below), which was, in effect, a demand for the implementation of Wolfenden.

The Lord Chamberlain's authority to license plays was finally abolished in 1968, the year after Wolfenden's implementation, and I recall a curious incident from that time. In 1966, I produced the BBC Home Service's Sunday lunchtime show, The Critics, and received the index file that recorded comments on contributors' performances. At the top of a fair number of cards were red asterisks, some accompanied by question marks. It suddenly dawned on me that the mark signified that someone was gay or possibly gay. I did the only thing I could do. I got a pen and put a red asterisk on every card.