One of the enduring, cruel legacies of British colonialism was that, even decades and centuries after nations threw off British rule, there remained a chilling similarity to the experience of boys and men with same-sex desires in places as far flung as India and Nigeria, Australia and Uganda, Pakistan and the United States.

As a child of affluent, cosmopolitan parents in 1960s Calcutta, I learned to feel like a criminal long before I knew what homosexuality was. At the age of 8, the taunting of my peers at the tony La Martinière for Boys taught me that I was a “sissy” and “pansy,” a loathsome freak forever to be cast out from the brotherhood of regular boys. I encountered even worse humiliation at the Doon School, India’s Eton or Andover, another warped boys-only world modeled on elite British schools. In my seven years there, I was subjected to unrelenting sexual assaults because of my pretty-boy looks and condemned for my femininity—often by the very boys who assaulted me.

Like my father and brothers before me, I went on to St. Stephen’s College in Delhi, run by the Church of North India. In this adult world, I had to confront a nullifying silence about homosexuality, which left me desperately fearful that there was no one else in the world with my sick longings. The silence was punctuated only by incidents that revealed an intense homophobia. My father and his friends spoke of men rumored to be homosexual in hate-filled tones that they did not use even when talking about the most vile politician or corporate swindler. (Strikingly, they never mentioned lesbians.) I was too unsure of myself then to wonder why homosexuals were the objects of such revulsion when there seemed to be no openly, avowedly gay men in India.

The upshot of all this was that by the time I had reached adulthood I was certain that homophobia was an Indian tradition, an immutable feature of our ancient civilization. This belief persisted even after I learned, while studying in the United States in the mid-1980s and hungrily reading the pioneering works of Western gay scholarship, that the Indian law criminalizing same-sex relations had been inherited from the colonial-era Indian Penal Code of 1860. It persisted despite the knowledge that Britain, arguably more than any other country, from the 16th century onward had developed a national mania for persecuting and killing homosexual men, and that criminal laws embodying this hatred had been exported to its colonies. (Women were assumed to be asexual, and were largely spared homophobic persecution in Britain, which helped explain why my father’s generation seemed so bizarrely unaware of lesbianism.)

And everything in my first stint living and working in India, as a journalist in New Delhi, reinforced my belief that homophobia was as much a part of Indian culture as it was of American or British culture. All the gay men and women I met, however privileged, lived in apprehension. Many were in sham marriages in a desperate attempt to hide their orientation. In the public parks, where gay men went to meet others and find sex or love (there being no gay bars), blackmail and beatings by the police were a constant danger. These signs of danger were a disquieting reminder of why my father had pleaded with me—when I was debating whether to return to India—to remain in the relative safety of the United States.

When I fell in love and began to live with my boyfriend in a committed relationship, my fears about Section 377, the part of India’s criminal code that outlawed homosexual relationships, intensified. I knew we were violating India’s criminal laws, despite being in the privacy of our flat. I knew we could be arrested and imprisoned, even sentenced to life imprisonment, the harsh maximum sentence.

And then one night in 1988, when I was aged 27, the worst of my fears became a reality. My boyfriend and I spent terrifying hours imprisoned at the local police station, accused of being “homos” and gaandu, the Hindi word for sodomites, because we lived together. Only my family’s privileged position ensured that we were eventually released unharmed—and that we could soon move abroad.

But then, beginning with my second return to India some years later to do research on rural poverty as well as on AIDS, my views about homophobia’s being an Indian characteristic began to change, first to ambivalence and then to the outright conviction that homophobia was an alien import with shallow roots.

I found that the further I went from the Anglicized enclaves that I had grown up in and the seats of power—the further from “brown sahib” Calcutta, avaricious New Delhi, and the police, meddling bureaucrats, and all the other functionaries of India’s vast government—the greater the gap between the homophobic views that I had witnessed all my life and what were clearly more accepting Indian values.

Thus, I saw that my aunts and other less Anglicized relatives in small towns handled the fact that I was gay in the most natural, constructive way I could have hoped for—as an unremarkable matter—rather than reacting with the homophobia I had initially encountered with my father. I saw that men in many parts of the country were raised in traditions that were far less macho than those of Anglicized India, and that this made them qualitatively more gentle and less prone to homophobia or hating “femininity” in men. I saw that many men and women treated same-sex desire as acceptable to an astonishing degree, very different from the bigotry displayed by Anglicized Indians or the antigay violence I had seen erupting regularly in the United States and Britain.

I saw too that the terrible persecution suffered by gays and hijras—the common term for India’s diverse traditional “third-gender” groups—was invariably the result of the exploitative license that Section 377 gave to powerful local men, such as the police, neighborhood thugs, and politicians—no different to their brutal treatment of any defenseless or impoverished group—rather than reflecting the workings of deeply held homophobia or transphobia. Even the grounds given for persecuting homosexuals or trans women lacked the bred-in-the-bone vehemence I had seen in the United States and Britain.

Over the years, while documenting the extraordinary changes sweeping India, I saw gay men and women, as well as hijras and modern-day trans women, striving to build families and safe communities for themselves, often in shanty towns and slums—and that in many cases their families, friends, and neighbors defended and supported them, certain that they had an equal right to love.

All these insights led me to realize that Britain’s centuries-old homophobia had lived on in independent India overwhelmingly by being internalized by conservative elites. The Anglicized class to which my family and I belonged had an outsize role in perpetuating archaic Victorian beliefs long after the ending of the British Raj. It says everything that the architect of this class of favored men—who were to be “Indian in blood and color, but English in taste, in opinions, in morals and in intellect”—the 19th-century imperial politician Lord Thomas Babington Macaulay, was also the primary author of Section 377. Unsurprisingly, the ascendant men who dominate the Hindu-supremacist Bharatiya Janata Party and its allied groups have also readily embraced the homophobia, pretending ignorance of its origins in the despised British Raj—conservatives are invariably homophobic, misogynistic, and indeed opposed to freedom for all but themselves.

It reflects India’s great cultural strength that most of Indian society withstood the spread of homophobia, despite 158 years of a law criminalizing same-sex relations. The positive result has been that not just on matters of same-sex desire but also on concepts of masculinity, gender expression, and intimacy, both authentic Indian traditions and contemporary grassroots trends are vastly more humane than the backward Victorian notions absorbed by influential sections of Indians.

It also reflects the growing maturity of India’s higher courts that they are now resolutely committed to righting the wrongs of the past and to embracing progressive, emancipatory changes, sometimes even raising the global bar for human-rights jurisprudence. Justice Indu Malhotra, the lone woman on India’s Supreme Court, movingly emphasized, in the recent judgment decriminalizing same-sex relations, that “history owes the LGBT community an apology for their sufferings.” In the last few years, the Supreme Court has made pathbreaking rulings on transgender rights—recognizing a third gender and ordering the government to provide them with affirmative-action benefits in education and jobs.

But while India is belatedly setting right archaic wrongs, the troubling truth is that Western nations have scarcely heeded the pointed lesson that applies to them: that hundreds of millions of people across generations and entire continents suffer unconscionable harm when wealthy, powerful nations set themselves up as global moral policemen. Ever since the days of President George W. Bush, the United States has been the worst offender, doing damage worldwide on everything from reproductive rights to the well-being and rights of sex workers and drug users. America’s countless would-be do-gooders—whether evangelicals, Hollywood celebrities, philanthrocapitalists, Gloria Steinem, or Nicholas Kristof—should learn some caution from the disastrous toll taken by imperial Britain’s civilizing missions.