FROM the mountain resort of Zakopane in the south to the Hel peninsula in the north, tens of thousands of Poles took to the streets last week in protest against proposed reforms that would have sacked all of the members of the Supreme Court and politicised the legal system. In Warsaw thousands marched night after night, holding candles and chanting “konstytucja!” (constitution). Even in the eastern city of Lublin, where the inhabitants tend to support the nationalist Law and Justice (PiS) government, the rallies drew hundreds of people. By one count, there were protests in over 220 cities.

They appear to have worked. On July 24th Andrzej Duda, the president and a trained lawyer, vetoed two of the three most controversial laws, saying they “would not strengthen the sense of justice”. But the threat to the rule of law in Poland is far from over. The proposed laws were only one part of a larger plan developed by PiS and its increasingly authoritarian chairman, Jaroslaw Kaczynski.

Since coming to power in November 2015, PiS has consolidated its support through a combination of unaffordable handouts, nationalist propaganda and fake news. (Polish state television declared the protests to be part of a plot to admit Muslim migrants, and linked them to George Soros, a Hungarian-Jewish philanthropist and bugaboo of European nationalists.) The party has also radically reshaped the Polish state, placing its cronies in the military, the civil service, state-owned companies and the constitutional tribunal. If it continues to do so unchecked, Poland, once seen as the most promising of the European Union’s new members, will emerge with its democracy weakened and its position in the EU isolated and fragile.

Unexpected comeback

PiS’s win in 2015 took many by surprise. Although it won only 38% of the vote, it gained the first outright majority of seats in Poland’s post-communist history. The party previously led a coalition government between 2005 and 2007, but its confrontational politics put many Poles off. So did its desire for a set of populist reforms which it calls the “Fourth Republic”. (Poles think of their current democratic state as the third in the country’s history.) According to Aleks Szczerbiak of the University of Sussex, the centre-right Civic Platform party won the subsequent election by framing it as “a choice between support for and opposition to the ‘Fourth Republic’.”

Civic Platform governed for eight largely successful years, but it underestimated a growing divide between haves and have-nots, or what locals term “Poland A” and “Poland B”. The latter is more nationalist, more populist and less Europhile. Overall, 72% of Poles are favourable towards the EU, the highest figure in Europe (see chart 1). But many have reservations. Fully 48% of PiS supporters think the EU should hand back some powers to the national government. Young people are more sceptical than older ones: one poll showed 27% of 18-29 year-olds favour “Polexit”, compared with 9% of those over 60.

PiS is not openly Eurosceptic, but it accuses the EU of discriminating against Poland in favour of longer-standing members, especially Germany. Since accession in 2004, about 2m Poles have emigrated to other EU countries, including many of the more cosmopolitan citizens. That has helped shift the balance towards PiS’s conservative, less urban voters. Although their towns have benefited from EU money—Poland is the largest recipient of EU structural funds—they are much poorer than thriving cities like Warsaw. The economic divide has helped fuel a turn towards nationalism. In the countryside, bumper stickers on cars bear the “PW” symbol of the Polish home guard in the second world war, a symbol banned during the Communist regime. Many people express exaggerated fears of Muslim migrants, although the only immigrants from outside the EU in most areas are Ukrainians. Some 66% of Poles view Muslims unfavourably, compared with 35% of Dutch and Swedes. PiS’s rejection of the EU’s demands to accept a few Syrian refugees plays well with these voters.

Redoing the foundation

Nationalist support has given Mr Kaczynski the leeway to try to build his “Fourth Republic”. Even before the proposed changes to the judiciary, his government was accused by the European Commission of undermining the rule of law by trying to pack the country’s constitutional tribunal and refusing to execute its decisions. The heads of the state-run media outlets have been replaced by PiS loyalists. The civil service has been purged, and the top jobs at several state-owned companies have gone to PiS supporters.

Meanwhile, Mr Kaczynski has made Polish politics toxic. He spouts conspiracy theories that the Civic Platform government caused the death of his twin brother Lech, who was president when he died in a plane crash in 2010 in Smolensk. (On July 18th, he shouted at the opposition in parliament: “You destroyed him. You murdered him.”) He launched a hopeless effort to block Civic Platform’s former leader, Donald Tusk, from being re-elected as president of the European Council in March. No other government went along.

Like its attacks on Civic Platform, PiS’s judicial reforms seem partly rooted in paranoia. Mr Kaczynski and his followers hold to an absurd theory that Poland’s liberals, along with opposition parties and other institutions, are secretly a continuation of the former communist nomenklatura. A centralised school-reform drive, which has generated strong resistance, shows Mr Kaczynski’s authoritarian streak too. Julia Pitera, a Civic Platform MEP who has known the PiS leader for three decades, says he was already a critic of the judiciary in the 1990s. “He is clearly irritated that there is some part of power not subordinate to him,” she says.

PiS argues that its proposed judicial system would be little different from other European ones in which justice ministers can nominate judges. The comparison is misleading. No European democracy would let the government sack and replace the entire supreme court, and the powers PiS proposes for the justice ministry are far greater than in other countries. “We have nothing near the [political] influence which the adopted law would have given in Poland,” says Werner Kannenberg of Neue Richtervereinigung, an association which campaigns for more judicial independence in Germany.

PiS also points to low public trust in courts, some of which are corrupt. Yet Poles trust their courts more than they do the government, albeit less than the EU or the Catholic church. “In almost all post-communist countries, lower courts are not models of efficiency and transparency,” points out Kim Lane Scheppele, an expert on eastern Europe at Princeton University. Poland’s may need gradual reform, but they do not need a sudden purge.

They may get one anyway. Although Mr Duda promised to veto and revise the two laws concerning higher courts, he signed a third one giving the government more control over ordinary courts. The justice minister will be able to sack their presiding judges. Lower mandatory retirement ages will allow the government to install more new judges. As for the other two laws, Mr Duda may simply make “cosmetic changes”, says Krystian Markiewicz, the head of the largest judges’ association.

The protests this month might seem encouraging to opposition politicians. Yet the protests strove for political neutrality; there were virtually no party banners. PiS is still well ahead in the polls (see chart 2).