Our scriptures have many elaborate and extensive references to sex changes and alternate sexual identities.
Although they never mention homosexuality or bisexuality directly, yet there are tales of Gods or people whose attributes or behaviour are symbolic. They can be interpreted as bisexual or transgender or as having elements of gender variance.
This is a story of the Chandravanshis
After Sagar Manthan, Vishnu as Mohini becomes pregnant by Shiva, and gives birth to Ayyappa. In the Mahabharata, Amba is reborn as Shikhandini to Drupada the king of Panchala. She turns to male Shikhandi with a boon from a Yaksha in order to revenge herself on Bheeshma.
There is a similar story of Ila/Sudyumna where two genders exist in a single body.
This story has been recorded as a conversation between Arjuna’s grandson, Pareekshit and Sage Shukdeva in Bhagwat Purana. When Pareekshit asks about the origin of his Chandravanshi dynasty and its relation with the Suryavanshis, Shukdeva narrates this story to him.
According to the story, to Surya and Sangya a son Vaisvrata Manu was born. It is said that all the dynasties of humans have originated from Manu. Manu remained childless for a long time after his marriage to Shraddha. He decided to pray to the Gods for a son to perpetuate his bloodline. With the help of his guru Sage Vashishtha he conducted a fire sacrifice in the honour of twin Gods Mitra and Varuna. They appeared and granted his wish for a child.
A boon turned a girl into a boy
A girl Ila was born to Shraddha. Manu was not satisfied, because he had desired a son. He asked Vashishtha to use his power to turn the child into a boy. Vashishtha turned Ila into Sudyumna a male. But destiny had its own plans. Sudyumna was riding near Mount Sumeru during a hunting expedition with his men. Following a deer they entered a grove called Sukumara. The moment his retinue reached the centre, they all turned female, men, king and horses.
The grove was a private bath for Goddess Parvati. To guard her privacy, Lord Shiva had enchanted the place. Any male would turn to female if he set his foot inside. Sudyumna sent for Sage Vashishtha, who tried to appease Shiva to pardon him and restore his masculinity.
Shiva could not reverse the effect of enchantments but he could alter them a bit. He granted that Sudyumna would alternately live as a female and male both. He would forget everything he did in his alternate identity as a woman when he turned into a man. His memory would switch too, to save him from living with guilt. Vashishtha accepted fate. He left Ila in the grove. He knew once he turned into Sudyumna, he would return home.
Sudyumna lived alternately as a man and a woman
Roaming in the woods Ila met planet Budh, the illegitimate son of Chandra the Moon God and Tara. Budh was very knowledgeable and pious. He proposed to Ila and they married. After a month Ila turned into Sudyumna. He totally forgot his alternate existence and marriage.
Budh accepted fate and accepted Sudyumna as his disciple. For a year, one month he enjoyed marital bliss with Ila and the next he taught Sudyumna the edicts of the Vedas. Their son Pururava was born to Ila. Budh then disclosed the secret to Sudyumna.
Sudyumna returned to his kingdom with the child. He married again and had three more sons, Utkal, Gaya and Vimal. Pururava still remained his favourite. Every alternate month, he retired to his private quarters to live life as a woman.
The throne went to the Chandravanshis
The alternating identities and his unexplained absence from the throne every other month, interfered with Sudyumna’s prestige as a king. He finally announced Pururava as his successor and retired to the woods.
Vaisvrata Manu had many other sons. Among them, Ikshvaku was a very valiant king and being the grandson of Surya his descendants were known as Suryavanshis. Since Pururava was the grandson of Chandra, his descendants were known as Chandravanshis.
Although this story describes the transformation of Sudyumna to Ila as complete physical transformation, it could be a euphemistic representation of his dual sexual identities in a single body – a bisexual person, who lived both as a man and a woman.
Ref: Shrimad Bhagwat Purana: 9.1.1-9.1.42 (Canto 9, Chapter 1, verse 1 to 42)