Nonbinary genders are a group of people who cannot be totally classified as males or females, which are the known gender binaries. The earliest encounter with people of nonbinary genders in Islam was in the Rashidun era, during the era of the First caliph. These types of people were known by a term in Classical Arabic, Mukhannathun which means one who is feminine or who looks like a woman in act. Mukannaths took roles that were typically carried out by women. Mukhannathun was known to exist in the early Islamic eras and before Islam.
A number of Ahadiths recorded the use of Munkannathun, where they served as maids to wealthy women during early days of Islam because of the belief that mukhannathun do not have sexual interest in females, but this does not state that they are gay, but that they lack such desires. Many Ahadiths state where the prophet Muhammad, peace be upon him, had cursed Mukhannathun with their female kinds, and instructed muslims to send them away.
Aisha, who was the wife of the prophet, peace be upon her, said in an Ahadith that Mukannath was usually with the Prophet’s wives. He was thought to be among those who were free from such urges. One day, Prophet Muhammad, Allah’s peace and blessings be upon him entered the rooms of one of his wives while a mukannath was around, while that mukannath was describing the qualities of a woman, saying: When she comes forward, she would come forward with four folds of her stomach, as she goes backward, did so with eight folds of stomach. Prophet Muhammad was convinced the mukannath pretended.