Munich’s football stadium was not, in the end, illuminated in rainbow colours for a Germany vs Hungary Euro 2020 match last week in response to an egregious anti-LGBT+ law passed by Hungary’s parliament; Uefa vetoed the idea as “political”. The EU, to its credit, had no such hesitations. Prime Minister Viktor Orban faced an unusual and often personal display of outrage at a leaders’ summit; European Commission president Ursula von der Leyen spoke of “shame”. After years of clashes with the EU over his erosion of democratic norms, Orban may finally have stepped over the line.

The offending law bans portrayal of homosexuality or transgender people on TV and media before a late-night watershed and in sex education in schools. Hungarian channels have said even some of the Harry Potter films could be affected. Adding insult to injury, lawmakers appended the legislation at the last moment to a bill to increase sentences for paedophiles, indirectly equating homosexuality with offences against children.

Hungary’s government insists the law restricts only what can be shown to children and so does not discriminate towards gay or transgender adults. But the legislation steps up the culture war Hungary, and nearby Poland, are waging with much of the rest of the EU. Budapest opened this new front late last year with legal changes whose effect was to bar same-sex couples from adopting children.

Orban’s rightwing Fidesz party has long claimed to support “traditional” family values. Its anti-LGBT+ moves, though, appear less a reflection of conviction than an attempt to shore up its conservative rural base ahead of parliamentary elections next year. After three successive victories, it faces a six-party opposition alliance with a joint programme and candidates. Orban’s tactics echo those of Russian president Vladimir Putin, who signed an “anti-gay propaganda” law in 2013 in a conservative tilt after protests the previous year.

Fidesz is also extending its strategy of vilifying threats or enemies against which it claims to defend Hungarians. The first targets were the mostly Muslim migrants with which it claimed the EU planned to swamp countries such as Hungary. The LGBT+ law was passed days before an Orban speech attacking Brussels for trying to build a quasi-Soviet “empire” and setting out a plan to roll back its powers.

Critics in Hungary note many older EU member states had anti-LGBT+ restrictions until relatively recently. But von der Leyen and leaders who spoke out at the summit are right to list dignity, equality and respect for human rights as fundamental EU values. Failure to defend these would undermine the EU’s mission to promote freedom and justice. By triggering a culture war, Orban’s government deflects attention from the EU’s concerns over its attempts to undermine democratic and judicial checks and balances. Fidesz and loyal media can claim to its electorate that Brussels is penalising the country over a law against paedophilia.

Planned EU legal action against Hungary’s law could be lengthy. A mechanism tying disbursement of EU structural funds to respect for the rule of law is still subject to a legal challenge from Hungary and Poland. But with the commission due to sign off shortly on Hungary’s plans to spend €7bn of EU recovery fund money, Brussels and other capitals could signal to Budapest that they will make especially strict assessments of whether economic reform commitments are being met unless it backs off on its culture war. To protect its values, the EU will need to use financial as well as legal leverage.