The court in the central city of Changsha dismissed the suit brought against the local civil affairs bureau for refusing to issue the couple a marriage registration certificate.
The couple's lawyer Shi Fulong said he expected the judge would rule against them but not so soon within just a few hours. "It goes against the spirit of the laws of the people's republic of China," Shi said.
The lawsuit comes amid growing awareness of lesbian, gay, bisexual and transgender issues in China, where society and the government have generally frowned on non-traditional expressions of gender and sexuality.
China doesn't legally recognize same-sex marriage and officials with the central government have said they do not see the law changing soon.
More From This Section
Sun, his partner Hu Mingliang, and the lawyer entered Changsha's Furong District courthouse today morning amid cheers from roughly 300 supporters, some of whom had waited outside since 5 am or traveled overnight from neighboring provinces.
Sun said the police had earlier visited him at the apartment he shares with Hu to try to talk him out of pursuing the lawsuit, but left after he reiterated his determination to press forward with the case.
"I hope I can pave the way as far and wide as possible so that people who want to do the same will see how much we have tried and what possibilities can there be," Sun, 26, told The Associated Press in an interview the night before the hearing.