Hungary's National Assembly approved new legislation on June 15 that would ban sharing information about sexual orientation or gender identity with minors.
The vote was a lopsided 157-1.
The bill was introduced by the right-wing Fidesz party, the ruling party associated with Prime Minister Viktor Orban. It also got support from the even more right-wing Jobbik party.
All the opposition parties – badly outnumbered by Fidesz – boycotted the session in protest.
"On this shameful day, the opposition's place is not in the parliament but on the streets," Budapest Mayor Gergely Karacsony wrote on Facebook.
Human rights groups denounced the bill, saying that the law could be used to stigmatize and harass residents because of their sexual orientations and gender identities.
Thousands of LGBTQ activists and allies held a protest in Budapest on June 14 in an unsuccessful effort to stop the legislation from passing.
More than a dozen local organizations, including Amnesty International Hungary and LGBT rights organizations, argued in a statement after the vote that the legislation is not in line with Hungarian society, which is largely accepting of LGBT people.
"(It) also clearly infringes the right to freedom of expression, human dignity, and equal treatment," the statement said.
Dunja Mijatovic, the commissioner for human rights at the Council of Europe, the continent's leading human rights body, also asked Hungarian lawmakers to reject the legislation, saying it reinforced prejudice against LGBTQ people.
Lawmaker Gergely Arato, of the Democratic Coalition parliamentary grouping, said the measure violates the standards of parliamentary democracy, rule of law, and human rights.
Government spokespeople said the bill was necessary for "the protection of children" from alleged LGBTQ pedophiles.
Csaba Domotor, the Fidesz state secretary, noted that the legislation includes the introduction of a searchable registry of convicted pedophiles.
"Pedophiles won't be able to hide any more – there are similar solutions in other countries, too. The criminal code will be even more strict. Punishments will be more severe. No one can get away with atrocities with light punishments and parole," he said.
Officials in other EU countries condemned Hungary's action.
"Today's decision in #Hungary's parliament represents another severe state discrimination against #LGBTIQ people," Deputy Foreign Minister Michael Roth of Germany tweeted June 15 after the new legislation passed.
"This law goes against everything we regard as our common European values. Full solidarity and support for LGBTIQ people in Hungary."