Britain's High Court on Tuesday ordered the government to change its instructions for the 2021 census, and compel transgender people to give their legally recognised sex.
The court ordered the government's Office for National Statistics to rewrite its guidelines on how people should describe their sex, after the campaign group Fair Play for Women complained that it allowed people to define their own sex.
"The guidance is wrong. It does not match the question being asked," Judge Jonathan Swift said before the March 21 census.
"[Fair Play for Women has] a strongly arguable case on the proper meaning of sex ... as recognised by law and not the sex with which the person self-identifies."
The decision comes amid an increasingly bitter row over trans rights in Britain, where the government last year abandoned plans to make it easier for people to change their sex on official documents, after heated debate.
The original ONS guidance said: "For those whose gender is different from their sex registered at birth, who may find the question difficult to answer, the answer they provide does not need to be the same as their birth certificate."
Fair Play for Women, which says it campaigns for women's gender-based rights, said on its website that the office had redefined sex "to include self-declared gender identity", which prevented the collection of accurate data on sexual inequality.
Mr Swift granted Fair Play for Women's request to seek a full judicial review of the matter, provisionally next week.
In the meantime, the ruling said census respondents must give the sex on their birth certificate or gender recognition document, which allows trans people to gain legal recognition of their new gender and name.
To receive a gender recognition certificate, they must live in their acquired gender for two years and have a medical diagnosis of gender dysphoria, or the discomfort people can feel if their gender identity does not match their body.