BERLIN — Germany’s highest court has decided that people must be allowed to be entered in official records as neither male nor female, saying in a ruling published Wednesday that authorities should create a third identity or scrap gender entries altogether.

The Federal Constitutional Court ruled on a case in which a plaintiff, identified by advocacy group Dritte Option only as Vanja, born in 1989, sought to have their entry in the birth register changed from “female” to “inter/diverse” or “diverse.”

Officials rejected the application on the grounds that the law only allows for children to be registered as male or female, or for the gender to be left blank.

The plaintiff argued that that was a violation of their personal rights. In a three-year legal battle, Vanja provided courts with a genetic analysis showing the plaintiff has one X chromosome but no second sex chromosome. Women have two X chromosomes, while men have one X and one Y chromosome.

The supreme court found that the law protects sexual identity, which has a “key position” in how individuals perceive themselves and are perceived by others. It said that “the sexual identity of those people who can be assigned neither to the male nor the female sex is also protected,” and said the constitution also protects them against discrimination because of their gender.

File - In this July 11, 2017 photo, judge Ferdinand Kirchhof holds his hat at the Federal Constitutional Court in Karlsruhe, Germany. Germany’s highest court has ruled that authorities must allow people to be entered in official records as something other than male or female. The Federal Constitutional Court published its ruling Wednesday Nov. 8, 2017 in the case of a person who had an application rejected to have their entry in the birth register changed from “female” to “inter/diverse” or “diverse.” (Uli Deck/dpa via AP,file) (Associated Press)

The government has until the end of 2018 to draw up new rules.

The court said that authorities have two ways to ensure that the rules comply with the constitution. It said that they could decide to do without any gender entry in civil registers but could also “create the possibility for the affected people to choose another positive designation of their sex that is not male or female.”

It didn’t specify what that should be.

Dritte Option, which has campaigned for a third gender option and was involved in preparing the case, wrote on Twitter that it was “completely overwhelmed and speechless.” It added that “this borders on a small revolution.”

The minister for families in Chancellor Angela Merkel’s outgoing government, Katarina Barley, said a third gender option was “overdue.” Barley’s center-left Social Democrats have vowed to go into opposition after Germany’s September election, but Merkel’s conservatives are negotiating with two socially liberal parties to form a new administration.

Interior Ministry spokesman Johannes Dimroth said the government is studying the verdict and will abide by the court’s December 2018 deadline.

Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.