Homosexuality has been documented in China since ancient times. According to one study by Bret Hinsch, for some time after the fall of the Han dynasty, homosexuality was widely accepted in China but 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 homosexuality in China had been legal, except for a period between 1979 and 1997 where male anal sex was punishable as "hooliganism".
In a survey by the organization WorkForLGBT of 18,650 lesbians, gay, bisexual and transgender (LGBT) people, 3% of males and 6% of females 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.
There was a step forward for the China LGBT community after the Weibo incident in April 2018, where the public outcry over the platform for banning homosexual content led the platform to withdraw the decision. Yet, in 2021 Weibo censored the accounts of numerous LGBT student organizations without any prior warning.
Traditional terms for homosexuality included "the passion of the cut sleeve" (), and "the divided peach" (). 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" (), "allied brothers" (), and "the passion of Longyang" (), referencing a homoerotic anecdote about Lord Long Yang in the Warring States period.