GLASGOW — A popular tabloid called Patrick Harvie, the leader of the Scottish Green Party, a “Green threat to the family” when he ran for Parliament in 2003 — not because of his politics but because he is bisexual. When Ruth Davidson became the first openly gay leader of the Scottish Conservative Party in 2011, she was labeled the “kickboxing lesbian.”

By the time Kezia Dugdale, the leader of the Scottish Labour Party, came out in April, it was hardly considered news at all.

In the span of a generation, Scotland has shed much of its traditional social conservatism and enthusiastically embraced diversity in sexuality, a process led and reinforced by a remarkable transformation in its political culture.

Homosexuality was illegal in Scotland until 1980 — in England it was decriminalized in 1967 — and as recently as 2000, billboards financed by a Christian millionaire campaigning to uphold a ban on schools’ talking about homosexuality urged Scots to “Protect Our Children.”