Japan’s Supreme Court has upheld a law that effectively requires transgender people to be sterilized before they can have their gender changed on official documents.

The court said the law is constitutional because it was meant to reduce confusion in families and society. But it acknowledged that it restricts freedom and could become out of step with changing social values.

Takakito Usui, a transgender man, cries while speaking during a press conference after Japan's Supreme Court handed down the decision in Okayama, Japan, on Jan. 24, 2019. Kyodo News via AP / AP

The 2004 law states that people wishing to register a gender change must have their original reproductive organs, including testes or ovaries, removed and have a body that “appears to have parts that resemble the genital organs” of the gender they want to register.

The unanimous decision by a four-judge panel, published Thursday, rejected an appeal by Takakito Usui, a transgender man who said forced sterilization violates the right to self-determination and is unconstitutional.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Usui, 45, had appealed to the top court after he unsuccessfully requested lower courts to grant him legal recognition as male without having his female reproductive glands surgically removed.

Despite the unanimous decision, presiding justice Mamoru Miura joined another justice in saying that while the law may not violate the constitution, “doubts are undeniably emerging,” according to Usui’s lawyer, Tomoyasu Oyama.

The two judges proposed regular reviews of the law and appropriate measures “from the viewpoint of respect for personality and individuality,” according to Japanese media reports.

The Supreme Court decision ended Usui’s legal battle, but he and his lawyer said the opinions in the ruling left them with hope.

“I think the ruling could lead to a next step,” Usui told a news conference. “I hope to find what constitutes a family of my own that does not fit the traditional mold.”

Human Rights Watch said the Supreme Court ruling was “incompatible with international human rights standards, goes against the times and deviates far from best global practices.” The New York-based group said the ruling tolerates grave human rights violations against transgender people.

There is a growing awareness of sexual diversity in Japan, but it is often superficial and generally limited to the entertainment industry. In a country where pressure for conformity is strong, many LGBTQ people hide their sexuality even from their families because of a fear of prejudice at home, school or work.

Japan does not legally recognize same-sex marriages. As LGBTQ rights awareness has gradually grown in recent years, some municipalities have begun issuing partnership certificates to ease problems in renting apartments and other areas, but they are not legally binding.

Lawmakers in the conservative ruling party have repeatedly come under fire for making discriminatory remarks about LGBTQ people. Earlier this year, Katsuei Hirasawa, a veteran lawmaker, was widely criticized for saying that “a nation would collapse” if everyone became LGBTQ. Last year, another ruling party lawmaker, Mio Sugita, was condemned after saying in a magazine that the government shouldn’t use tax money for LGBTQ rights because same-sex couples aren’t “productive.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM