In the first ruling of its kind in China, a Beijing court said on Friday that a psychiatric counseling center was in the wrong when it attempted to cure a 30-year-old man of homosexuality with a mix of hypnosis and electric shocks.

Gay rights activists have said they hoped the lawsuit will help put an end to the practice of “gay conversion” therapy in the country.

“We’re incredibly happy,” said Yang Teng, the plaintiff in the case. Mr. Yang earlier told China Real Time (which previously quoted him using the pseudonym Xiao Zhen) that staff at a clinic in the southwestern city of Chongqing told him they could cure his homosexuality, then put him in a state of light hypnosis and shocked him with electrodes every time he thought of gay sex.

“In her decision, the judge said that homosexuality is not a disease, therefore the clinic had no basis to undertake treatment,” he said.

The decision by the Haidian District Court in northern Beijing ends weeks of tension after the court missed a deadline to issue a ruling in the case. The presiding judge, Wang Chenghong, couldn’t be reached on Friday. The Beijing High People’s Court, which is responsible for handling questions from foreign media, didn’t immediately respond to a request for comment.