The law recently passed by Hungarian lawmakers violates "the fundamental values of the European Union," the bloc's chief Ursula von der Leyen said.
The European Union's chief executive on Wednesday threatened legal action against Hungary for legislation that restricts young people's access to information about LGBTQ issues.
Last week, the Hungarian parliament approved the controversial bill, which has to be signed by the president to take effect.
"This Hungarian bill is a shame,'' European Commission President Ursula von der Leyen said in a news conference.
"This bill clearly discriminates against people based on their sexual orientation. It goes against the fundamental values of the European Union: human dignity, equality and respect for human rights," von der Leyen said. "I will use all the powers of the Commission to ensure that the rights of all EU citizens are guaranteed. Whoever they are and wherever they live within the European Union.''
Hungary's right-wing Prime Minister Viktor Orban said in an interview with German news agency dpa that the bill was aimed at protecting children.
On Tuesday, Hungary's Foreign Minister Peter Szijjarto said the law would allow "parents to educate their kids regarding sexual orientation until the age of 18."
"This law does not say anything regarding [the] sexual orientation of adults,'' he said.
Orban, speaking to dpa, argued that Hungary was in fact a safe country for the LGBTQ community nowadays.
"In communist Hungary, homosexual people were persecuted. Today the state not only guarantees the rights of homosexuals but actively protects them," Orban said.
On the other hand, critics of the bill say it conflates pedophilia with non-heterosexuality, fearing that its vague wording can be used to persecute members of the LGBTQ community.
The issue surrounding the Hungarian law has courted particular attention in the past day owing to the Euro 2020 football competition.
Europe's football governing body, UEFA, denied a request by Munich to light its stadium in LGBTQ rainbow colors for the Germany-Hungary Euro 2020 match on Wednesday.
However, several stadiums around Germany will be illuminated in rainbow colors in protest of the Hungarian law and UEFA's decision.
A joint statement initiated by Belgium and signed by 14 EU member states, including Germany, France, Spain and Italy, voiced "grave concern" at the law.
"Stigmatizing LGBTIQ persons constitutes a clear breach of their fundamental right to dignity, as provided for in the EU Charter and international law," the statement read.
fb/msh (AFP, AP, dpa, Reuters)