It’s no secret that many LGBTQ people have found refuge in the dharma, and it’s easy to see why. It helps us work with the wounds of homophobia, recognizing internalized self-hatred for the delusion and dukkha [suffering] that it is. Yet when queer people interact with the dharma, there is often something missing: visibility. It’s nice that Buddhism doesn’t say many bad things about us, but does it say anything good? Where are we among the Dogens and Milarepas and Buddhaghosas?

This is not, of course, a question limited to Buddhism. Everywhere, queers have been erased from history. Often we find ourselves only when we are being persecuted; we have to read in between the lines of our interlocutors, trying to reconstruct a lost past.

But there is much to be gained from the effort. Finding ourselves in history, for better or for worse, reminds us that we have one. We can see the different ways in which gender and sexuality were understood across time and cultures, and we are reminded that sexual and gender diversity has always been a part of human nature.

The history of queer Buddhism does not always paint a rosy picture. We find a mixed tapestry that includes stories of acceptance and persecution as well as examples that are problematic or offensive to modern Western sensibilities. While books can be (and have been) written about this subject, here I will limit myself to four examples that demonstrate the breadth of queer experience throughout Buddhism.

1. Mild offenses

First, and I think least interestingly, there are various levels of injunctions against male-male sexual behavior. What’s interesting here, apart from the mere visibility—yes, the monks were doing it with each other—is the minor nature of the offense. In the Theravadan monastic code, for example, sexual (mis)conduct between monks or novices was no more egregious than any other sexual misconduct, and did not warrant additional sanctions. The offense is similarly minor in Vajrayana monastic communities, leading both to consensual “thigh sex” (frottage) among monks, and, tragically, to many documented instances of sexual abuse.

Conflicting statements by His Holiness the 14th Dalai Lama have reflected this ambivalence. In 1994, he said that as long as there were no religious vows at issue, consensual same-sex intimacy “is OK.” But in an interview published two years later, he said that only when “couples use organs intended for sexual intercourse” could sex be considered “proper.” After meeting with gay and lesbian activists in 1997, he noted that the same rules applied to straight and gay people alike, and that they were not part of the direct teachings of the Buddha and thus might evolve over time. In 2014, he reiterated the view that for Buddhists, homosexual acts are a subset of sexual misconduct, but that this was a matter of religious teaching and did not apply to people of another or no religion. Other rinpoches have disagreed and fully affirmed gay and lesbian lives. There is no clear position.

2. Gender-nonconforming ancestors

Second, there are several instances of what today might be called gender-nonconforming people in Buddhist texts, now newly accessible thanks to historian Jose Cabezon’s recently published 600-plus page tome, Sexuality in Classical South Asian Buddhism. Many Theravada and Mahayana texts, for example, refer to the pandaka, a term which, Cabezon shows, has a wide variety of meanings, encompassing “effeminate” male homosexuals, intersex persons, and others who exhibited non-normative anatomical, gender, or sexuality traits. (The term pandaka is often translated “eunuch,” but insofar as a eunuch is someone who chooses to be castrated, this is an inaccurate translation. Because of the breadth of the term, Cabezon himself renders it “queer person.”)

By and large, the pandaka is not depicted positively. As Cabezon describes in great detail, the Theravadan monastic code prohibits the ordaining of a pandaka—“the doctrine and discipline does not grow in them,” it says. And a Mahayana sutra called A Teaching on the Three Vows says bodhisattvas should not befriend them. But to me, just the visibility of the pandakais encouraging. Here we are! And if we have been stigmatized, well, as Cabezon notes, that is hardly comparable to how queer people have been treated in other religious traditions.

3. Sexual samurai

Third, there is a fair amount of male-male homoeroticism in Buddhist textual history. The Jataka tales [parables from the Buddha’s past lives] include numerous homoerotic stories featuring the future Buddha and the future Ananda; in addition to the tales themselves apparently being told without a sense of scandalousness, these stories suggest an interesting appreciation of the homoerotics or at least homosociality of the teacher-disciple relationship. Like Batman and Robin, Achilles and Patroclus, and Frodo and Sam, the Buddha and Ananda are, emotionally speaking, more than just friends.

Japanese Buddhism probably had the most fully developed form of same-sex eroticism—nanshoku—that endured for hundreds of years, beginning in the 1100s and fading out only in the 19th century, under the influence of Christianity. These relationships—sometimes called bi-do (the beautiful way) or wakashudo (the way of the youth)—were pederastic in nature, often between an adolescent boy (probably aged 12–14) and a young man (aged around 15–20), and thus not role models for contemporary LGBT people, but a queer love nonetheless.

As with Greek pederasty, these relationships combined a sexual relationship with a mentoring relationship. And as in the Greek model, there were clear rules and roles that needed to be followed; nanshoku was not hedonism but a homosexuality that was socially constructed.

The legendary founder of the institution of nanshoku was the 12th-century monk Kukai, also called Kobo Daishi (“the great teacher who spread the dharma”), who was also credited with founding of the Shingon school of Japanese esoteric Buddhism, which incorporates tantric practice. Although there is not much historical evidence for this, it’s interesting that the institution of nanshoku became linked with tantra, which has its own polymorphous eroticism in the service of awakening.

This culture has left us the greatest collection of homoerotic Buddhist texts of which I am aware. Nanshoku Okagami (the Great Mirror of Male Love), published in 1687 and available in a fine translation by Paul Gordon Schalow, is a collection of love stories, some requited and others not, between samurai warriors and Buddhist monks, actors, and townspeople. Now available in multiple translations, the book is an almost unbelievable artifact of Edo-period hedonism, warrior love conventions that closely resemble the Mediterranean ones, and Romeo-and-Juliet-like stories of forbidden love, impossible love, and star-crossed lovers. If you can get past our cultures’ very different ethics regarding intergenerational sex, it’s an amazing queering of history.

4. Gender fluidity

Finally, the fluidity and play of gender within some Buddhist texts is often inspiring but also frequently problematic. Numerous Buddhist enlightenment stories feature women suddenly transforming into men, for example. On the one hand, that’s kind of awesome from a queer and trans point of view. On the other hand, it’s often a way of explaining how deserving women can become fully enlightened—by becoming men.

That highlighting the role of a prominent female bodhisattva like Kuan Yin or a female deity like Tara has enabled many Western dharma centers to manifest their commitments to gender egalitarianism—awesome. That Kuan Yin is but one manifestation of the male bodhisattva Avalokiteshvara—less awesome. And yet, that a male bodhisattva occasionally manifests as a female figure—maybe more awesome.

So too the feminization of the principle of wisdom, prajnaparamita, and the Vajrayogini, who is female, erotic, and enlightened. These figures may be gender-essentialistic, gender-binaried, and heteronormative, but especially for Westerners, they productively queer the assumptions of what is masculine and feminine.

These examples of queerness in Buddhist text and history are just a sampling; there are many more. When queers look at these echoes in the past, we’re doing several things: We are finding ourselves in history and theology. We are claiming and acknowledging our existence, albeit in different forms from those we know today. And we are, hopefully, keeping our senses of irony and historicity intact. This isn’t gay-hunting or a naïve apologetics that siphons off the bad and leaves in only the good. We are, instead, searching for a usable past, not with a faux nostalgia or appropriative orientalism, but with a sophisticated relationship to what has gone before and what is present now.

Correction (7/5): An earlier version of this article translated Kobo Daishi as “the great master from Kobo.” A more accurate translation is “the great teacher who spread the dharma.” The article also identified Kukai as the founder of the Shingon school, which is disputed.