The court also ruled that the couple would have to cover the litigation fee, which is 50 renminbi, or $7.70, by themselves.

The case has galvanized some gay rights advocates in China. Photographs and video taken in Changsha showed many people gathering outside the courthouse in the morning to support Mr. Sun and Mr. Hu.

The case has also received considerable attention on Chinese social media as a test of the authorities’ attitude toward same-sex marriage. Internet users said that although the result was unsurprising, the couple had achieved a big step.

“In this era, being able to knock open the court’s door is already a victory. Keep going,” a user with the handle Garden on the Roof wrote on Weibo, China’s equivalent of Twitter.

Mr. Sun said he and Mr. Hu were “definitely disappointed.”

“But after seeing so many people are paying attention to this case, we feel very hopeful,” he added.

Li Yinhe, a Chinese sexologist who has backed same-sex marriage, said the ruling was expected. Even if the couple appealed, she said, the court was unlikely to eventually accept their argument.

“Many other countries that have since allowed same-sex marriage didn’t explicitly ban same-sex marriage before, either,” she said.