BERLIN — The European Court of Justice on Wednesday ordered Poland to pay a daily penalty of $1.2 million until it complies with an earlier ruling regarding its controversial overhaul of the country’s judiciary.

Compliance “is necessary in order to avoid serious and irreparable harm to the legal order of the European Union and to the values on which that Union is founded,” the court said in a statement. 

Poland and the European Union are in the midst of a bitter dispute over changes to the country’s court system by Poland’s ruling Law and Justice party.

This month, Poland’s top court ruled that the country’s own laws had primacy over those of the European Union, shaking the foundations of the 27-member bloc’s accepted legal order. That led to questions over whether Poland can continue to remain in the union if it does not accept its legal framework, though the Polish government has dismissed talk of a “Polexit” — Poland leaving the European Union — as “fake news.”

In July, the European Court of Justice ruled that Poland’s system of picking judges was “not compatible” with European law as it was open to direct political influence.

The Luxembourg court has ordered Poland to dissolve the disciplinary chamber of its Supreme Court. As pressure has mounted, Polish Prime Minister Mateusz Morawiecki has said that will happen by the end of the year but has accused Brussels of attacking Poland’s sovereignty.

Speaking to the Financial Times in recent days, Morawiecki had accused Brussels of making demands with a “gun to our head.” The dispute has also delayed Poland’s $42 billion share in Europe’s pandemic economic recovery package, and Morawieki told the newspaper that if Brussels withholds promised funds, it could start a “third world war.”

“European governments that are not willing to respect the ground rules of liberal democracy undermine all trust,” Alexander De Croo, the Belgian prime minister, said at a college opening in Bruge.

The European Union is not a “cash machine,” he said, adding that “you cannot pocket all the money but refuse the values.”

The European Court of Justice last month ordered Poland to pay $580,000 a day over its failure to shut down Turow coal mine, near the Czech border. Czech authorities had lodged a complaint that the mine had an environmental impact on its side of the border.

Christian Wigand, a spokesman for the European Commission, said that if the fines were not paid by Poland, they would be offset by “payments due to the member state concerned.”

Poland’s Law and Justice party had framed the changes to its judicial institutions as reforms to address bias and corruption. In reaction to Wednesday’s court ruling, Marcin Romanowski, the country’s deputy justice minister, suggested suspending Poland’s contributions to the European Union budget in retaliation, saying such a move might bring bureaucrats in Brussels “to their senses.”

“The nonelected and undemocratic bodies of the E.U. will not put themselves above Polish society and block reforms against its democratic will,” he said.

Kamila Gasiuk-Pihowicz, a parliamentarian with the opposition Civic Platform, accused the ruling party of “arrogance and irresponsibility.”

“Not only have they destroyed the justice system, but they have also done it at the expense of Poles,” she said.

Dariusz Kalan in Warsaw contributed to this report.