The history of lesbian, gay, and bisexual people in China spans thousands of years. Unlike the histories of European and European-ruled polities in which Christianity formed the core of heavily anti-LGBT laws until recent times, non-heterosexual states of being were historically treated with far less animosity in Chinese states. For a period of the modern history of both the Republic of China and People's Republic of China in the 20th century, LGBT people received more stringent legal regulations regarding their orientations, with restrictions being gradually eased by the beginning of the 21st century. However, activism for LGBT rights in both countries has been slow in development due to societal sentiment and government inaction.
Imperial China
Homosexuality has been documented in China since ancient times. Homosexuality was regarded differently among social classes and the sexes, meaning that it was at times acceptable but other times not.
The Intrigues of the Warring States, a collection of political advice and stories from before the Han dynasty, refers to Duke Xian of Jin (reigned 676–651 BC) planting a handsome young man in a rival's court in order to influence the other ruler and to give him bad advice. The historian Han Fei recorded a more exalted example in the relationship of Mizi Xia (彌子瑕) and Duke Ling of Wei (衛靈公). Mizi Xia's sharing of an especially delicious peach with his lover was referenced by later writers as Yútáo, or "the bitten peach". Another example of homosexuality at the highest level of society from the Warring States period is the story of Lord Long Yang and the King of Wei.
Scholar Pan Guangdan (潘光旦) came to the conclusion that many emperors in the Han dynasty had one or more male sex partners. Many were recorded in detailed biographies in the Memoirs of the Historian by Sima Qian and the Records of the Han by Ban Gu. Grand Historian Sima Qian notes that, unlike female wives and concubines, the male companions of the emperors were often admired as much for their administrative abilities as for their sexual abilities: — Those who served the ruler and succeeded in delighting his ears and eyes, those who caught their lord's fancy and won his favor and intimacy, did so not only through the power of lust and love; each had certain abilities in which he excelled. Thus I made The Biographies of the Emperors' Male Favorites. The proverb says, "No amount of toiling in the fields can compare to a spell of good weather; no amount of faithful service can compare to being liked by your superiors." This is no idle saying. Yet it is not women alone who can use their looks to attract the eyes of the ruler; courtiers and eunuchs can play at that game as well. Many were the men of ancient times who gained favor this way.
The last of these emperors overlapped chronologically with "all but one" of the first fourteen Roman emperors held to be bisexual or exclusively homosexual by historian Edward Gibbon. The Emperor Cheng of Han, also named Liu Ao, was a bisexual person. According to the Book of Han, he had a male lover named Zhang Fang. They were deeply in love with each other, but were forced to depart by Liu Ao's mother, the Grand Empress Dowager Wang. Besides this lover, he also had many famous empresses and imperial concubines, like Zhao Feiyan, Zhao Hede, Empress Xu and Ban Jieyu.
The Han emperor most strongly devoted to his male companion was Emperor Ai, who "by nature...did not care for women", and who attempted to pass the throne on to his lover, Dongxian (董賢). The story of Emperor Ai which most struck later writers, however, was when the Emperor carefully cut off his sleeve, so as not to awake Dongxian, who had fallen asleep on top of it. The cut sleeve was imitated by many people at court and became known as Duànxiù, or "breaking the sleeve". This phrase was linked with the earlier story of Mizi Xia's bitten peach to create the formulaic expression yútáo duànxiù (余桃断袖) to refer to homosexuality in general.
Throughout written Chinese history, the role of women is given little positive emphasis, with relationships between women being especially rare. One mention by Ying Shao, who lived about 140 to 206, does relate palace women attaching themselves as husband and wife, a relationship called dui shi. He noted, "They are intensely jealous of each other."