WARSAW—Tens of thousands of protestors marched through Warsaw and other Polish cities late Sunday to oppose a court ruling that European Union legal judgments have become incompatible with the Polish constitution, a decision protesters fear could prompt Poland to follow the U.K. out of the bloc.

Waving EU and Polish flags, demonstrators held banners reading “I’m Staying in Europe” and “No Polexit!”

Unlike...

WARSAW—Tens of thousands of protestors marched through Warsaw and other Polish cities late Sunday to oppose a court ruling that European Union legal judgments have become incompatible with the Polish constitution, a decision protesters fear could prompt Poland to follow the U.K. out of the bloc.

Waving EU and Polish flags, demonstrators held banners reading “I’m Staying in Europe” and “No Polexit!”

Unlike in the U.K., an overwhelming majority of Poles wish to stay members of the EU—as do Hungarians, another Central European country whose government is in regular conflict with the bloc over where the EU’s powers end and national sovereignty begins.

But on Thursday, Poland’s Constitutional Tribunal ruled that the process of European integration encoded in EU treaty law has reached what it called a “new stage” that is incompatible with the Polish constitution, and that the latter should take precedence when the two conflict. Before joining the EU in 2004, Poland agreed to the primacy of EU law. Poland’s ruling party says the EU has overstepped its authority.

In Brussels, a spokesman for the European Commission, the EU’s executive arm, on Monday gave no timeline for responding to Poland. EU officials fear a domino effect and gradual disintegration of the EU’s legal and political authority if one country can overrule EU rules and EU court decisions.

“If you allow all these fundamental principles of European integration to be hollowed out and ignored, then this is eventually the end of the EU,” said Piotr Buras, head of the European Council on Foreign Relations’ Warsaw office.

The ruling was celebrated by Poland’s ruling Law and Justice party, a conservative nationalist faction that says it doesn’t want to leave the EU but does want to roll back its supranational authority, especially over Poland’s court system.

“The bodies of the European Union act outside the powers conferred on them by the Republic of Poland,” said the ruling, led by Chief Justice Julia Przyłębska. If that is allowed to stand, the ruling said, “Poland cannot function as a sovereign and democratic state.”

The trigger for the constitutional standoff was changes Law and Justice made to Poland’s court system after winning presidential and parliamentary elections in 2015. The new President Andrzej Duda first refused to allow several constitutional judges appointed by the outgoing government to take their posts, instead installing Law and Justice-backed candidates, including Ms. Przyłębska, to the top court. That move breached Polish legal codes, the European Court of Human Rights later ruled.

A sign during Sunday’s protest in Warsaw reads, ‘One leader, one party, one creed. Once it was Stalinism, now it’s Kaczynski’ism,’ referring to ruling party leader Jaroslaw Kaczynski.

Photo: Czarek Sokolowski/Associated Press

Law and Justice then created a disciplinary chamber to penalize judges who otherwise enjoy broad protection from political or parliamentary influence. The ruling party said the system was necessary to make judges accountable to elected members of parliament, and to purge the handful of communist-era judges still serving in Poland.

In July, the European Court of Justice, the EU’s top court, ruled that the disciplinary chamber threatens the independence of the national court system—making it incompatible with EU law—and should be suspended. Poland hasn’t so far complied with that ruling.

Instead, Prime Minister Mateusz Morawiecki asked his country’s constitutional tribunal to decide whether national law should supersede EU law on the issue.

The differing viewpoints have set up a clash over whether Poland can remain a member of the EU while also creating a system of governance in which the ruling party wields political authority over the court system.

Also at stake are tens of billions of dollars in EU aid for Poland that the bloc is considering pausing, on the grounds that Poland’s government no longer has a sufficiently independent court system to ensure the funds are properly spent. Some governments, including Ireland and the Netherlands, have paused extraditions to Poland—a major rupture in the daily functioning of the EU—on concerns that Polish courts can no longer guarantee a fair trial.

Aleks Szczerbiak, a professor of Politics and Contemporary European Studies at the University of Sussex, said that for Law and Justice, the issue is sovereignty. “On something like this, it’s very difficult to see how they could retreat,” he said. “And the question is how far does the EU political establishment want to push on this?”

The EU’s top court will soon decide how much to fine Poland for ignoring its decision. Some expect a record daily fine. Poland could use last week’s ruling to ignore the fine but Brussels could recoup the money from Poland’s EU budget revenue.

Brussels is already using other financial leverage to squeeze Warsaw. Since May, the EU has withheld a decision on disbursing the first chunk of the €36 billion—$41.6 billion—in grants and loans Poland is due under the EU’s pandemic economic recovery plan, in large part because of concerns over judicial independence.

“The question is how far does the EU political establishment want to push on this?”

— Aleks Szczerbiak, a professor at the University of Sussex

The European Commission could also trigger a rule-of-law instrument agreed last year that allows Brussels to withhold regular budget payments if corruption or rule-of-law issues endanger the proper use of EU funds. Poland remains the EU’s biggest net recipients of EU money, at about €12.5 billion in 2020.

Yet EU officials see political risks in escalating the fight. Poland in the short-term could block many areas of EU decision-making that require unanimity, including decisions around the EU’s ambitious climate plans.

Brussels also knows it must carry most member states along with its plans, not just western European countries like France and the Netherlands, whose governments have long criticized Warsaw.

While France and Germany were among those to condemn Poland’s rulings, but Hungarian Prime Minister Viktor Orban, a close ally of the Polish government, warned Brussels to respect Poland’s sovereignty.

An EU leaders meeting in Brussels next week will let European Commission President Ursula von der Leyen gauge the mood on Poland’s decision.

Write to Drew Hinshaw at drew.hinshaw@wsj.com and Laurence Norman at laurence.norman@wsj.com