(CNN) A wave of joy and relief swept through India's LGBT community last week following a landmark decision by the country's Supreme Court to legalize consensual gay sex.

The announcement that Section 377, a British colonial-era law prohibiting "unnatural acts," would be annulled was met with jubilation by rights activists, many of whom had campaigned for years to end the archaic legislation.

But while India's LGBT population embraces its new found freedoms, millions across the globe continue to wait in hope.

Of the 71 countries around the world in which same-sex sexual relations are illegal, it's no coincidence that more than half are former British colonies or protectorates , according to research provided by the International LGBTI Association.

In most of these countries, legislation outlawing consensual gay sex was inherited from British rule and left in place following independence.

Speaking at a meeting of Commonwealth Heads of Government on April 17, British Prime Minister Theresa May expressed "regret" at the British Empire's long legacy of homophobic legislation.

"I am all too aware that these laws were often put in place by my own country. They were wrong then, and they are wrong now," she told the gathered leaders.

"As the UK's Prime Minister, I deeply regret both the fact that such laws were introduced, and the legacy of discrimination, violence and even death that persists today."

How homophobia came into law

Across the world, from South America to Asia, an estimated 49 formerly British-administered countries continue to criminalize homosexuality.

Out of those, 31 still have laws based on the original colonial anti-LGBT legislation, according to Lucas Mendos, co-author of the 2017 ILGA "State-Sponsored Homophobia ." This includes countries as diverse as Malaysia, Pakistan and Uganda.

Despite the prevalence of anti-LGBT laws throughout the former British Empire, there was no blanket decree outlawing homosexual relations.

Instead, it was the sensibilities of individual colonial administrators which led to the first laws and then their quick spread across the Empire from 1860 onwards.

Enze Han, author of "British Colonialism and the Criminalization of Homosexuality," said the laws were partly the product of a strict Victorian moral code, which defined any sexual activity not for procreation as taboo.

"(The British also) had this conception that the 'Orient,' the non-Western subjects, were overly erotic and over-sexed, and that's the reason why they were worried young colonial officers going abroad would be corrupted by those sexual acts," he said.

Many of the laws which were put in place under the colonizers have long since been amended or even strengthened by local governments, which Mendos said could also show that colonial legislation at least partially reflected conservative opinions common within those countries at the time.

"(They) embraced it as something which is part of the culture," Mendos told CNN.

An alternative explanation would be that conservative attitudes found in former colonies are illustrative of the long term effects of British prohibitions on local opinions.

According to Han, once a law is in place, it's difficult to dislodge, both from a legal and physiological perspective. "The law book says it's illegal so that means that it has this general societal inference, changing the social normative views of gay sex," said Han.

Cultural traditions overturned

The strict Victorian-era laws brought in by British colonists often clashed with decades, or even centuries of complex local cultural attitudes to sexuality. India, in particular, had traditionally maintained a flexible, non-prescriptive view of sexuality and gender roles.

But the British administrators paid little attention to local attitudes when they criminalized same-sex relations in 1860, and declared the country's centuries-old old custom of transgender hjiras to be "unnatural."

India was in fact one of the first colonies to outlaw LGBT sexual relations under British imposed legislation. Han, the University of Hong Kong professor, told CNN the Indian laws were then used as a "template" for other colonies.

Indian LGBT activist Dhrubo Jyoti, who helped lead the campaign for the decriminalization of gay sex in India, told CNN that same-sex communities loathed the law not just because it was "wrong," but also because it was "alien."

"This law was not ours. This was not a law that has organically developed in our society," said Jyoti.

Jyoti pointed out that the law didn't only trap members of the LGBT community in the closet, it also invited other forms of discrimination, providing a cover for blackmail and harassment, and even sexual assault.

Indian LGBT activist Dhrubo Jyoti.

Political oppression

The British colonial laws haven't just been used to repress and harass the LGBT community. In many places they're an active tool to clamp down on political dissent.

As was the case in India, Malaysia also criminalizes same-sex relations under Section 377, based on the original British colonial legislation.

Under Section 377, prominent Malaysian opposition politician Anwar Ibrahim was imprisoned twice on sodomy charges which many viewed as spurious and politically motivated.

Ibrahim was freed earlier this year under a new Malaysian government, but local activist Pang Khee Teik said it was too soon for the country's LGBT population to celebrate.

"During the Parliament session, you could hear they were very concerned that they are seen as being open to supporting LGBT, and they're worried this might cost them political points," said Pang of the country's new government.

It isn't just the anti-sodomy laws which worry Pang. British colonial-era anti-sedition laws, imposed in 1948, have been used to quell dissent in Malaysia, making it hard to protest for LGBT rights.

"The sedition laws ... are still being used to target and silence activists," Pang said. "I don't think us looking at the sodomy law as the only British legacy that is problematic is good enough."

Malaysian LGBT activist Pang Khee Teik.

Growing conservative Islamic sentiment in the country makes the colonial-era legal framework increasingly concerning for activists, as life gets progressively tougher for LGBT Malaysians.

Two gay women were caned in Malaysia in early September for attempting to have sex in a parked car, the first time the punishment had been open to the public, while 20 men were charged after a gay club was raided in Kuala Lumpur in August.

"We don't know what's going to happen in the future. That's the general feeling," Numan Afifi of LGBT activist group the Pelangi Campaign told CNN in September.

'We want to be free'

At least 15 former colonies have decriminalized same-sex relations in the years since independence, with India being the second country this year following a Trinidad and Tobago ruling that the laws were "unconstitutional."

Among them were mainly developed Western economies, including Australia, Canada and South Africa.

In many former British outposts the laws still stand, or are even being strengthened, particularly in Africa.

In December, a LGBT film festival in Uganda was raided by police and shut down. Police told organizers they had been warned the films were "pornographic," but the festival team said they weren't breaking any laws.

As in Malaysia and other British colonies, same-sex relations are outlawed in Uganda under current laws based of the old British penal code. Gay Pride events in Uganda are regularly shut down by authorities and the parliament has attempted to put in place strict laws outlawing the "promotion of homosexuality."

A UN special rapporteur who visited the former British colony of Ghana in April reported widespread discrimination and even violence against LGBT people. Same-sex relations have been illegal in Ghana since the colonial era, and the current criminal code uses similar language to the original laws.

In early 2017, Mike Oquaye, a prominent Ghana politician, called for stricter laws on same-sex relations, referring to it as an "abomination " and deeply concerning the LGBT population.

"The government should recognize that we are human beings, with dignity, not treat us as outcasts in our own society," a 40-year old lesbian from Ghana told Human Rights Watch in January.

"We want to be free, so we can stand tall in public and not deal with obstacles and harassment daily."

But change is slowly coming across the world. In India, still flush with joy and celebration, LGBT activist Jhoti said he was hopeful about the future.

"It's going to take a long time but this is the first step. Without decriminalization, a further fight for rights cannot happen," he told CNN.