The short answer
Yes, people who had same-sex relationships appear in Chinese historical records going back more than two thousand years. However, the modern identities “gay,” “lesbian,” “bisexual,” “transgender” and “queer” are recent concepts, so historians are careful about applying them to people in the past. What the sources show is a range of attitudes that varied by period, class and gender, and that were usually quite different from both modern acceptance and modern ideas of sexual orientation.
A note on terms
Ancient Chinese texts did not describe fixed sexual identities. They described relationships and behavior, often in the context of courts, family duty and social rank. For this reason, it is more accurate to say that same-sex relationships existed in early China than to say that “LGBTQ people” were categorized or recognized as such. Gender diversity is even harder to document, though some historians point to individuals in later periods who crossed gender lines in dress or performance.
Same-sex relationships in early records
Several famous stories come from early historical and philosophical writing. One tells of Mizi Xia, a favorite of Duke Ling of Wei in the Spring and Autumn period, who is said to have offered the duke a half-eaten peach. The story gave rise to the expression “the shared peach.” The Han dynasty historical records report that several emperors had male favorites. One of the best known is Emperor Ai and his favorite Dong Xian, which is the source of the expression “the cut sleeve” or “passion of the cut sleeve”: the emperor is said to have cut off his sleeve rather than wake Dong Xian, who was sleeping on it.
These accounts were written by court historians and often used such relationships as a way to comment on a ruler’s judgment or on court politics. They tell us something about the elite world, but little about the lives of ordinary people.
What about women?
Evidence for women’s same-sex relationships is much sparser, partly because the surviving sources were written mostly by men and said little about women’s private lives. Later periods offer somewhat more, such as references in Ming and Qing writing to affection and companionship between women, but scholars treat these with caution, and what we can say about the earliest centuries is very limited.
Later periods: Ming and Qing
By the late imperial period, literature, drama and fiction openly depicted male same-sex relationships, especially among the elite and in theater circles. Social expectations still centered on marriage and continuing the family line, so a man might have relationships with other men while also marrying and having children. In some regions, local customs of male partnership have been described by historians, though details vary and are debated. In the eighteenth century the Qing legal code began to penalize certain same-sex acts more explicitly, an example of how attitudes shifted over time.
How the religious traditions fit in
Confucian thought placed great emphasis on family continuity and filial duty, which shaped social pressure to marry and have children. Classical Confucian texts do not have extended discussions of the subject; how later thinkers and modern communities interpret them is covered in is Confucianism against homosexuality. Daoist and Buddhist traditions, likewise, have a range of views. See is Taoism LGBTQ friendly and how does Buddhism view LGBT for those topics. In general, religious texts in China tended to be less concerned with the subject than some other traditions were, but later moral norms, especially around monastic celibacy and family duty, mattered.
Changing laws and attitudes
In the nineteenth and twentieth centuries, contact with Western medical and legal ideas, together with reform movements, brought new language and new stigma in many places. Modern attitudes today vary widely by region, generation and legal setting, and the situation of LGBTQ people in China, Taiwan, Hong Kong and elsewhere is quite different in each place.
Why the evidence is limited
Anyone studying this period faces gaps. Records come mainly from literate men at court, and many writings have been lost or were edited by later authors. Translations also sometimes shape how the passages are read. For these reasons, scholars generally prefer to describe what specific sources say rather than make broad claims about how “China” viewed same-sex love.