Unlike the Abrahamic faiths, Hindu tradition does not have a canon or canonical laws. It is an inclusive tradition. Nothing is banned outright, though some practice(s) are not approved and are sometimes even punished.
Hindu tradition has recognised the wide range of human sexual diversity and banned none, though non-mainstream versions have always been relegated to the margins of society. Srimad Bhagvatam (4.28.61) says, “Sometimes you think yourself a man, sometimes a chaste woman and sometimes a neutral eunuch. This is all because of the body, which is created by the illusory energy. This illusory energy is My potency, and actually both of us – you and I – are pure spiritual identities. Now just try to understand this. I am trying to explain our factual position.” This verse has generally been understood as recognition of three genders and sexual orientations.
Several texts, including the Kama Sastra and Narada smriti, and medical texts like the Caraka Samhita (4.2), Sushruta Samhita (3.2) and Smriti Ratnavali, and Sanskrit dictionaries and lexicons like Amarakosa and Sabda-Kalpa-Druma include references to tritiya Prakriti (eunuchs, or persons who cannot be exclusively categorised as male or female). This third gender has generally been held to include bisexuals, homosexuals, intersexuals, transexuals and asexuals. Patanjali takes notice of the third sex, as do some medieval era Jaina Acharyas who note that third-sex desire can be very intense.
The overall attitude has been one of accommodation. The Dharma sastra and dharma sutra texts maintain that the third gender should be minimally maintained by their family members as they usually do not have children (Arthasastra 3.5.30-32), and do not inherit property. The Vasista Dharmasutra advises the king (State) to maintain third-gender citizens with no family members and the Arthasastra forbids vilification of third-gender men or women (3.18.4-5). In the Mahabharata, king Virata shelters Arjun as the eunuch Brihannala; he teaches dance to the royal princess who later becomes his daughter-in-law.
In totality, ancient India was not enthusiastic about same sex relations, but persecution was generally absent in Hindu society.
Adapted & abbreviated from a longer article, by noted writer Sandhya Jain. The original article has a specific context in Indian politics, and the parts of it which relate specifically to culture, spirituality and tradition have been extracted here.