Transgender people in Japan must still effectively be sterilised before their gender can be changed after the supreme court ruled against a move to change the current law.
Japan's supreme court has upheld a law that effectively requires transgender people to be sterilised before their gender can be changed on official documents.
The court acknowledged "doubts" were emerging over whether the rule reflects changing social values, but said the law was constitutional.
The decision, published on Thursday, upholds a law that requires any individual wishing to change their documents have "no reproductive glands or reproductive glands that have permanently lost function," referring to testes or ovaries.
It also requires the person to have "a body which appears to have parts that resemble the genital organs of those of the opposite gender."
The appeal was filed by Takakito Usui, a transgender man who wants to change official documents that identify him as female.
But the panel of four justices ruled unanimously to throw out Usui's appeal, declaring the law constitutional.
They said the measure was intended to prevent "problems" in parent-child relations that could lead to societal "confusion" and "abrupt changes" in society.
The judges said they recognised the invasive nature of the law, adding that legislation should be regularly reviewed as social and family values change.
In an additional opinion, presiding justice Mamoru Miura joined another justice to say that while the law may not violate the constitution, "doubts are undeniably emerging".
"Suffering related to gender, felt by people with gender identity disorder, is also the problem of society as a whole, which should encompass the diversity of sexual identity," the additional opinion said.
The ruling ends Usui's legal battle, but his lawyer said parts of the decision could boost a campaign to press lawmakers to change the rule.
In 2004, Japan passed legislation that says people suffering from “gender identity disorder” could change their gender, as long as they underwent sterilisation.
Mr Usui said: “The essential thing should not be whether you have had an operation or not, but how you want to live as an individual.”
The World Health Organisation called for an end to forced sterilisation in 2014, calling it a “violation of fundamental human rights”.