Germany's highest court has ordered that a "third gender" be recognised on official documents, including birth certificates, in a decision met with praise by intersex campaigners.
Broadly speaking, intersex people are those who do not fit into standard biological definitions of male or female.
The Federal Constitutional Court said that current regulations, which allowed people to be recognised as either, male, female or with a blank entry, were discriminatory, and that having a sexual identity was a basic individual right.
The court ordered parliament to regulate for the official recognition of a third gender on birth registers by the end of 2018.
"We are completely overwhelmed and speechless. That's a small revolution in the gender area," activist group Third Option wrote on Twitter.
The plaintiff who brought the case to the court is an intersex person who was legally regarded as a woman despite chromosome analysis showing them to be neither male or female, Deutsche Welle reported.
They were appealing decisions from lower courts who had refused a request to change their birth certificate from "female" to "diverse" or "inter/diverse".
In overturning previous rulings, the Federal Constitutional Court said that authorities must now ensure that gender recognition complies with citizens' constitutional rights to a gender identity. Another possibility, the court added, was scrapping gender entry on civil registers altogether.
An estimated 0.05-1.7% of the global population is intersex, according to the UN. Famous intersex people include Belgian model Hanne Gaby Odiele and South African athlete Caster Semenya.
Germany is thought to be the first country in Europe to make legal provisions for intersex babies, while New York issued its first intersex birth certificate last year.
In May, France rejected the option of "neutral sex" on official documents, after its highest appeals court ruled against a request from a person born with neither a penis or vagina.
Federal Minister of Family Affairs Katarina Barley welcomed the decision, saying: "The new government must take immediate action to ensure that the Federal Constitutional Court's requirements are implemented. I expressly plead for a comprehensive reform of the law for trans- and intersexuals in accordance with the Council of Europe's guidelines."