TODAY in Scotland, the rights of LGBT citizens are enshrined within the law. Non-heterosexual men and women can marry, contract civil partnerships, adopt children and engage in careers where their right to work is protected. We have Scottish party leaders who identify as gay or bisexual and in a recent human rights report, Scotland topped the European league for LGBTI legal equality.

While all this is to be heartily welcomed, it shouldn't be forgotten that for many years, Scotland lagged behind England and Wales in recognising sexual diversity, and as the TV documentary Coming Oot! A Fabulous History Of Gay Scotland will show, gay and bisexual men and women long occupied a kind of hinterland, starved of acceptance, recognition and subject to intense homophobia.

Scotland did not decriminalise gay sex between consenting male adults until 1980, 13 years after England and Wales. South of the Border, change had been precipitated by the 1957 Wolfenden Report, which recommended the decriminalisation of homosexual acts between consenting male adults in private.

Here in Scotland, there was a fly in the ointment: James Adair, a former procurator fiscal and religious conservative, produced a minority report which disagreed fundamentally with any moves towards decriminalisation. Open homosexuality would, he argued, elicit "disgust" from the public, promote male prostitution and lead to moral turpitude, enabling "perverts to practise sinning for the sake of sinning".

The General Assembly of the Church of Scotland also opposed change, stating that "the only legitimate context for sexual activity was through life-long marriage between a man and a woman", and that relaxing the law would "lead to further and greater depravities".

The Scottish press largely supported James Adair's objections, with the Daily Record carrying out a reader poll which it claimed reflected Scotland’s desire not to relax the laws on homosexuality.

The biggest obstacle, however, was a legal one. Because Scots Law requires the corroboration of two independent, and different, sources of evidence, homosexual acts committed behind closed doors – although illegal – were rarely prosecuted. The law, therefore, focused on men who conducted their sexual lives in parks, toilets, and tenement closes: activities that weren't the focus of the England and Wales reforms. The consensus seemed to be that if private sex between males wasn't prosecuted in Scotland, why go to the bother and expense of changing the law?

Of course, this ignored the civil liberties of Scottish LGB men and women, who were largely unaware of the selective application of the law and continued to feel heavily burdened by their sexuality. As Coming Oot will show, many tried desperately to look, or even be, heterosexual.

When I interviewed 24 gay and bisexual men for my book Queer Voices In Post-War Scotland: Male Homosexuality, Religion And Society, I found that a quarter of them had married in an attempt to think or become "straight". "I believed I was on this big Kinsey Scale," one told me, referring to a theory developed in 1948 by American sexologist Alfred Kinsey. Getting married, he thought, would help "nudge" him along the scale – presumably towards heterosexuality.

Other men compartmentalised their lives, presenting a heterosexual facade to family and work colleagues and secretively visiting bars where gay men were known to meet. "Robert", born in 1937, told me: "I might go out on a conventional social evening [in the late 1950s] with people I work with ... and then I would go out, unknown to them." Seeking other men for love, companionship or sex, presented problems for many; physical threats, robberies and police intimidation were all common experiences. "Stephen" recalled being harassed by two undercover police officers in the public toilets in Clyde Street, Glasgow, after he'd been caught short on the way home from a night out in the early 1960s. They encouraged him to end his miserable "queer" life by jumping from Glasgow Bridge.

Some medical practitioners even took it upon themselves to attempt "treatments" aimed at limiting same-sex desire. "Morris", born in 1933, was prescribed female hormonal treatment by his GP, which offered little in redirecting his sexual desires, but worryingly, caused physical anomalies, such as increased breast size and the disappearance of facial hair.

Some sought help from psychiatrists, many of whom appear to have been ahead of contemporary opinion in post-war Scotland, offering supportive advice and encouraging homosexual men to accept their sexuality.

But not everyone in the profession was so enlightened. During the 1960s, "Frankie”, born in 1943, was sent to a child psychiatrist, only to be psychologically scarred by warnings of paedophilia and the devastation that homosexuality would wreak upon his life and career.

In a society still dominated by the two main churches, gay men struggled to accept their sexualities when powerful institutions condemned what they were. Yet, despite the rhetoric forwarded by the Church of Scotland in Assemblies during the 1950s, there was considerable ambivalence within the church. The church committee which had examined the findings of the Wolfenden Report was split, with the investigating sub-committee in favour of its recommendations, only to be overruled by the main committee. But, by the 1960s the Church of Scotland was viewing homosexuality in a much more flexible manner, even if it still considered being gay a "handicap".

When Scotland’s first homosexual law reform organisation, the Scottish Minorities Group, was established in 1969, the Church of Scotland’s Moral Welfare Committee appointed an official representative to liaise with the group, which was given church premises in Edinburgh for its meetings. Reverend Ean Simpson, the Church’s representative, forwarded a more liberal agenda, and sought to “urge [the homosexual] to be the best kind of homosexual possible, ie – to be discriminating but wholehearted about his homosexual proclivities”.

No condemnation, no rhetoric. But relations between Simpson and the SMG eventually faltered over the reform group’s desire to start discos, social events and encourage the development of Edinburgh’s LGBT commercial scene. Enabling romantic, sexual and social possibilities was not, in Simpson's view, the aim of the group, and in the early 1970s, he ended the collaboration.

Having lost their meeting place, the group found an unlikely saviour in the Roman Catholic Church, which supplied premises and priests to speak at SMG meetings. Notable Catholic clergy such as Anthony Ross – future Rector of the University of Edinburgh – and Columba Ryan – Catholic chaplain to the University of Strathclyde – sought to build an inclusive relationship between religious orders and ordinary homosexuals, Catholic or not.

Ross was a pragmatist who was uncomfortable with restrictive doctrines, whether related to same-sex intimacies or pre-marital sex, and who encouraged a democratic approach to love and sexuality, which placed personal fulfilment and happiness above certain demands from religious texts. Without the support of the churches, and these individuals, the SMG would have struggled to develop during its early years, as "Walter", a founding member of the group, told me. The churches, he said, "deserve a lot of credit for being the only official arm of society that facilitated reform in any way".

While the SMG’s relationships with Scottish churches were largely positive, the group had little success with the police. Accusations were made that the police in Edinburgh, Glasgow and Dundee were harassing gay men, and lacked discretion when investigating homophobic crimes. Complaints about this directed at chief constables received short shrift. The uneasy relationship between the police and LGBT people also found its way into Glasgow’s few gay bars during the late 1970s. "Chris", a former bartender at Vintners, one of the first gay-friendly bars in Scotland, recalled the nightly visits by members of the constabulary: “They would come in for their drink at the end of the night and cause an atmosphere. They would expect their drinks to be on the bar, it was horrible, horrible. There was this sense that they were looking down on you, you were the scum of the earth, but they still came in for their drink and caused that feeling of intimidation.”

The chasm between Scotland’s LGBT population and the police was further widened by the realisation that in 1980, Grampian Police was issuing handbooks to officers which contained the following commentary: “It is a sad reflection on modern society that there are still to be found in our midst, persons who are so lewdly disposed that they will stoop to the most revolting and almost unbelievable acts of indecency ... The terms ‘sodomy’, ‘lewd and libidinous practices’ etc where used in law give little indication of the nature of these offences, the manner in which they are usually committed, and the evils they are liable to bring in their train ... The movements of persons of manifestly lewd disposition should always be closely watched as many and varied are the artifices employed by these persons to achieve their evil objects.”

Despite the SMG's tireless efforts to change attitudes, only a handful of the 24 men I interviewed had been aware of the organisation's existence, and feelings of isolation, of otherness, were persistent factors in their lives. In England, high-profile trials such as those involving Peter Wildeblood, Lord Montagu and Michael Pitt-Rivers in the 1950s brought homosexuality into the open. Here in Scotland, there were fewer platforms for discussion.

And while the London of the 1960s and 1970s presented citizens with notable LGB figures, from Quentin Crisp to Tom Robinson, there were few Scottish "role models". Those who were lesbian, gay or bisexual tended to migrate south – including artists such as the two Roberts, Colquhoun and MacBryde, and the writer Fred Urquhart. Those who did remain, such as the poet Edwin Morgan, never felt comfortable enough to reveal their sexuality until late in their lives.

Coming Oot also highlights the invisibility of lesbians in Scotland, untouched by legal sanctions but subject to the same discourses of deviance. While gay men were an issue for the authorities, lesbians occupied a strange hinterland where their sexualities, their rights to pleasure, were either ignored or viewed with passive distaste.

In a letter from the Crown Office in Scotland to the SMG in 1970, the Crown Agent makes a short but telling comment about the legal status of lesbians: “As far as female perverts are concerned, they have never been a problem to this Office.” Some lesbians felt sidelined by the male-dominated SMG, and most felt deeply isolated from Scottish society.

The isolation many felt, combined with the need for discretion, had a significant impact upon their later lives, with some feeling unable to participate in the more confident LGBT communities of the 1970s and 1980s. "Robert", reflecting on his life in Edinburgh during the 1950s and 1960s, told me: “I am deeply f***ing annoyed that I have got to this age and I’m still so unfulfilled in areas of having a good relationship, and what f***ing chance do I have now? I do feel quite resentful that I have been deprived of that.”

Yet in spite of the social opprobrium they faced, many LGB Scots continued to forge careers and relationships, explore their sexuality and seek fulfilling relationships. In doing so, with some courage, they also helped to change attitudes. While most of the LGB men and women I interviewed spoke of lost youth, of wasted years filled with fear and isolation, they also spoke of a growing sense of solidarity, unimaginable during the 1950s and 1960s, but within grasp by the mid 1970s.

"Chris" reflected on his emergence within Glasgow’s gay scene during this period: “It was a different bond, a commonality, and you stuck together. It was like another family.” For some, this new family was to replace the traditional familial bonds, which had often been damaged by decisions to "come out". In the late 1980s, "Ed", who had just found out he was HIV-positive, wrote to his mother to tell her that he was gay, and to reveal his diagnosis. Her reply was telling: “She wrote back saying that ‘the main thing is that you keep healthy but I think it’s against nature that you’re gay’.”

Coming Oot is an important piece of broadcasting, examining the mostly unknown gay history of Scotland, charting the law reform movement and examining just why the country had to wait until 1980 for homosexual law reform. What we are left with is the realisation that Scotland just didn’t like talking about sex, whatever colour. This led to a mystifying silence around LGBT rights; even the law seemed engineered to silence the "queer".

So, unlike in England where change was institutionally inspired, the drive for law reform here came from LGBT citizens themselves, tired of the silences, weary of the prejudices, keen to invoke a lost radical tradition and reshape the tired, dogmatic stereotype of traditional values.

We now live in a society where young LGBT Scots can have honest relationships with their peers and not feel they have to hide a hugely important part of themselves away as though it were shameful. Yet, it is important to appreciate how we have got here, and that for many older LGBT Scots the path to an enlightened Scotland was filled with many obstacles.

Jeffrey Meek is a social and cultural historian based at the University of Glasgow. His book, Queer Voices In Post-War Scotland: Male Homosexuality, Religion And Society, is published by Palgrave. He acted as historical consultant for Coming Oot! A Fabulous History Of Gay Scotland, which airs on BBC1 Scotland tomorrow at 10:35pm