Activists are hailing the ruling as the first such victory in a country where the LGBTQ rights movement is gradually emerging from the fringes.
The wife and relatives of the 38-year-old man, identified only by his surname, Yu, forcibly admitted him to the hospital in the town of Zhumadian in Henan province in 2015.
Doctors diagnosed him with “sexual preference disorder,” according to court documents obtained by the Associated Press. He was forced to take medicine and receive injections over 19 days, before finally walking free.
The court found that forcing him into a mental institution if he did not pose a danger infringed his rights.
Last month it ordered the hospital to publish a public apology in local newspapers and pay the man the equivalent of $735.
The court did not, however, rule an whether the practice of so-called “ex-gay” or conversion therapy was legal or ethical.
Homosexuality was considered a mental disorder in China until 2001, and attitudes remain conservative despite recent gains by LGBTQ activists.