April 21 (UPI) -- The European Union's top court ruled Tuesday that Hungary's anti-LGBTQ laws violated the bloc's values prohibiting discrimination and ensuring freedom of expression.

The European Court of Justice said the law Hungarian lawmakers approved in 2021 violated the EU's values as set out in Article 2 of its treaty, thus breaking its law. It's the first time an EU member state has been found guilty of breaking EU law based on its founding values, The Guardian reported.

The Hungarian law was ostensibly put in place to protect children from sexual abuse, increasing sentences for sex crimes and creating a public database of sex offenders.

But it also restricted LGBTQ content for students under 18. It also restricted advertising deemed to popularize same-sex relationships or genderqueer identities. The Hungarian Parliament overwhelmingly approved the legislation 157-1.

Related