In Uganda, two people who have sex could end up serving life sentences in prison if they happen to be the same gender. Should friends or family fail to tip officials off, they run the risk of joining them in jail under a law passed last week. The measure – which has to be signed off by the president – marks the culmination of a four-year campaign. "This is a victory for Uganda," said David Bahati, the MP behind the bill. "Parliament has voted against evil."
Most people in Britain would see bigoted Bahati as the real evil in this case. On the same day, the Nigerian senate passed an anti-gay bill, outlawing even membership of advocacy groups. Just days before, India's top court rejected a ruling decriminalising homosexuality and Australian judges struck down gay marriage laws, while Russia's preening president sanctions state prejudice, fuelling a climate of fear.
It's a depressing end to the year on one of the key human rights issues of our age. Yet we should not despair. Yes, these examples – and there have been other grotesque setbacks in the global fight for gay equality, to say nothing of beatings and murders – are disturbing. But we are in the midst of a worldwide revolution in which the tide is turning against homophobia.
Today there are 24 openly gay MPs in Westminster – and, remarkably, more on the Tory benches than those of other parties combined, which puts into perspective recent attempts to oust Crispin Blunt for "the final straw" of coming out and ridiculous rightwing rumbling over equal marriage. This concept was opposed by two-thirds of voters three decades ago, while nine out of 10 were horrified by gay adoptions; now only one person in five disapproves of gay relationships, and about half are comfortable with gay adoption.
Similar shifts can be seen elsewhere in the west and Latin America, driven by more tolerant and globalised generations. It is a quarter of a century since Denmark became the first country to permit civil partnerships, and now they are legal in 31, while 14 have endorsed gay marriage so far, along with 18 US states. The latest was the Mormon stronghold of Utah, although legal tussles continue.
A clear majority of Americans support equal marriage; a decade ago, the figure was less than one-third. Amid the furore we should not forget that, during my lifetime, four-fifths of Americans disapproved of interracial marriage; it was accepted by a majority there only shortly before the turn of the 21st century. A decade later, voters chose a black president.
Such transformations show how rapidly societies can alter norms. Global surveys show antipathy to gay men and lesbians falling fast, with just one in three saying homosexuality is never acceptable. There are signs of change in Asia, where a majority in Japan and the Philippines now accept homosexuality, and support for gay rights has more than doubled in South Korea in six years. Even in China and India there is evidence of a significant decline in hostility: this may be aided in India by reaction to judicial recriminalisation.
The most antediluvian attitudes are found in poorer countries with the highest rates of religiosity. Often they are the legacy of corrosive colonial codes: half the remaining sodomy laws are relics of British imperial rule. Yet even in Africa, where 38 countries ban homosexuality and fears have been whipped up by foreign evangelical groups, there is South Africa, which permitted same-sex marriage some seven years before Britain.
The journey towards genuine equality for lesbian, gay and transgender people is still long. It will speed up if the pope follows those important words saying he cannot judge someone for being gay with real action. Regardless, those recent setbacks should not cause despair, for the signs are that humanity is moving in the right direction.
Ian Birrell is a former deputy editor of the Independent and worked as a speechwriter for David Cameron during the 2010 election campaign.