EU leaders confronted Hungary’s prime minister Viktor Orban during an ill-tempered summit in Brussels, clashing over an anti-LGBTI+ law that has sparked widespread condemnation and suggesting that Budapest should quit the union.

Tensions ran high as a host of leaders demanded Orban’s ultra-conservative government repeal legislation that prohibits references to homosexuality or transgender issues in school material and media aimed at under-18s.

Brussels has said the bill equates homosexuality with paedophilia and violates EU fundamental values related to equality and discrimination.

Xavier Bettel, Luxembourg’s prime minister and the only openly gay leader in the European Council, and Mark Rutte of the Netherlands led the charge against Orban on Thursday night.

Rutte confronted the rightwing premier, asking why he wanted to remain part of the EU and suggested that Hungary trigger the Article 50 mechanism to quit the bloc unless Budapest changed its approach, diplomats told the Financial Times.

Ahead of the summit, Rutte described Hungary’s leader as “shameful”, and said Orban had “no business” in the EU. Micheál Martin, Ireland’s Taoiseach, said the anti-LGTBI+ bill was an example of “Hungarian authorities transgressing a fundamental value of the European Union”.

The conflict came to a head at the showdown summit after years of simmering frustration with Orban’s Fidesz government, which has been accused of violating the rule of law at home, misusing EU taxpayer money and launching assaults on the rights of minorities and migrants.

Judit Varga, Hungary’s justice minister, called Rutte’s comments “no more than another episode from the political blackmailing series. Hungary doesn’t want to leave the EU. On the contrary, we want to save it from hypocrites”, she wrote on Twitter.

Diplomats said Orban defended the legislation, arguing it was designed to protect children and maintain matters of sexual orientation for parents and not schools. He also claimed the law was misunderstood by its critics and not aimed at the gay community. “I am being attacked from all sides,” Orban said, according to officials familiar with the discussion.

During the exchanges, Luxembourg’s Bettel gave a personal account of how he came out as gay and the difficulties that some members of his family had in accepting his sexuality.

He accused the Hungarian bill of fuelling suspicion and divisions in society. “I did not become gay because of something I saw on TV,” said Bettel, according to diplomats familiar with the discussion.

Emmanuel Macron, France’s president, asked what had become of Orban, who had once been considered a liberal in the years after Hungary’s independence from Soviet rule.

Angela Merkel, Germany’s chancellor, who is attending her last EU summit before federal elections in September, said children who were in need of advice over their sexuality should be able to access support from the state, according to diplomats.

Criticism of the bill was widespread from all member states, with the exception of Poland and Slovenia, which supported Hungary’s position that parents should have the ultimate say on how children are educated.

Ahead of the summit, Ursula von der Leyen, European Commission president, had promised to use all available tools against the bill, which Brussels argues contravenes a number of EU laws, including the Charter of Fundamental Rights and EU audiovisual regulation.

Brussels will open another legal front against Budapest at the European Court of Justice, where Hungary has already been reprimanded over laws restricting academic freedom and migration quotas.