Hungary's parliament has approved a law that bans trangender people from changing the gender they were assigned at birth on official documents.
The law, proposed by the governing right-wing Fidesz party, passed by 133 votes to 57.
Rights groups fear it will worsen discrimination against LGBTQ citizens; an opposition MP said it was "evil".
But the government, led by PM Victor Orban, says it will end legal uncertainty.
The administration insists it will not prevent anyone expressing their identity.
The decision "to register children's biological sex in their birth certificates does not affect men's and women's right to freely experience and exercise their identities as they wish," the government's communications office said.
The law is part of a wide-ranging package of legislation, presented by Deputy Prime Minister Zsolt Semjen.
A backlog of applications going back three years will now be rejected.
Trans people and human rights groups say it is the latest blow in a war declared by the conservative-nationalist government against anyone who does not fit into their definition of a family, reports the BBC's Nick Thorpe in Budapest.
Tina Korlos Orban, vice president of advocacy group Transvanilla Transgender Association, told the Thomson Reuters Foundation: "We have no words to describe what we feel.
"People who haven't had suicidal thoughts for decades now are having them. People are in panic, people want to escape from Hungary to somewhere else where they can get their gender recognised."
Trans people fear that discrimination and worse will occur when they need to present official documents.
The legislation now goes to President Janos Ader, also a member of Fidesz, to be signed into law. Rights activists say they will try to persuade him not to.
Most European Union countries allow official documents to be changed to match gender identity, according to campaign group Transgender Europe.