Homosexuality in China has been documented in China since ancient times. According to one study, homosexuality was regarded as a normal facet of life in China, prior to the Western impact of 1840 onwards. However, this has been disputed. Several early Chinese emperors are speculated to have had homosexual relationships accompanied by heterosexual ones. Opposition to homosexuality, according to the study by Hinsch, did not become firmly established in China until the 19th and 20th centuries, through the Westernization efforts of the late Qing Dynasty and early Republic of China. On the other hand, Gulik's study argued that the Mongol Yuan dynasty introduced a more ascetic attitude to sexuality in general.
For most of the 20th century, homosexual sex was banned in the People's Republic of China until it was legalized in 1997. In 2001, homosexuality was removed from the official list of mental illnesses in China.
In a survey by the organization WorkForLGBT of 18,650 lesbians, gay, bisexual and transgender (LGBT) people, 3% of the males surveyed and 6% of the female surveyed described themselves as "completely out". A third of the men surveyed, as well as 9% of the women surveyed said they were in the closet about their sexuality. 18% of men surveyed answered they had come out to their families, while around 80% were reluctant due to family pressure.
Traditional terms for homosexuality included "the passion of the cut sleeve" (Chinese: 斷袖之癖; pinyin: duànxiù zhī pǐ), and "the divided peach" (Chinese: 分桃; pinyin: fēntáo). An example of the latter term appears in a 6th-century poem by Liu Xiaozhuo:
— She dawdles, not daring to move closer, / Afraid he might compare her with leftover peach.
Other, less literary, terms have included "male trend" (Chinese: 男風; pinyin: nánfēng), "allied brothers" (Chinese: 香火兄弟; pinyin: xiānghuǒ xiōngdì), and "the passion of Longyang" (Chinese: 龍陽癖; pinyin: lóngyángpǐ), referencing a homoerotic anecdote about Lord Long Yang in the Warring States period. The formal modern word for "homosexuality/homosexual(s)" is tongxinglian (Chinese: 同性戀; pinyin: tóngxìngliàn; literally: "same-sex relations/love") or tongxinglian zhe (Chinese: 同性戀者; pinyin: tóngxìngliàn zhě, homosexual people). Instead of that formal word, "tongzhi" (Chinese: 同志; pinyin: tóngzhì), simply a head rhyme word, is more commonly used in the gay community. Tongzhi (literally: "comrade"; sometimes along with nü tongzhi, Chinese: 女同志; pinyin: nǚ tóngzhì; literally: "female comrade"), which was first adopted by Hong Kong researchers in Gender Studies, is used as slang in Mandarin Chinese to refer to homosexuals. Such usage is seen in Taiwan. However, in Mainland China, tongzhi is used both in the context of the traditional "comrade" sense (e.g., used in speeches by Communist Party officials) and to refer to homosexuals. In Cantonese, gei1 (基), adopted from English gay, is used. "Gay" is sometimes considered to be offensive when used by heterosexuals or even by homosexuals in certain situations. Another slang term is boli (Chinese: 玻璃; pinyin: bōli; literally: "crystal or glass"), which is not so commonly used. Among gay university students, the acronym "datong" (Chinese: 大同; pinyin: dàtóng; literally: "great togetherness"), which also refers to utopia, in Chinese is becoming popular. Datong is short for daxuesheng tongzhi (university students [that are] homosexuals).