WARSAW—Imagine a government deciding one day that the country’s supreme court is corrupt and needs to be purged completely. A bill is introduced that will force all of the court’s judges to retire and be replaced—and it is pushed through with lightning speed and without regard for procedures. Unthinkable? Yet this is exactly what is happening here in Poland, until recently considered one of the biggest success stories of democratic transition in Eastern Europe.

This month the government’s most authoritarian tendencies were encouraged by the July 6 visit of U.S. President Donald Trump, and now a different sort of transition is underway—to what some call a “hybrid dictatorship.”

For anyone who values the checks and balances essential to democracy wherever it exists, the events of the last few days present a frightening precedent.

Shortly after Trump’s visit, which served as a ringing endorsement of the current illiberal government, the country is facing the most serious political crisis since the fall of the Iron Curtain in 1989.

The tensions between the government and the opposition have turned to unprecedented open hostility and threats; chaos and confusion reign in the parliament; and fears are widespread that the fate of Polish democracy itself may well hang in the balance.

The crisis started coming to a head last week when, emboldened by Trump’s visit and taking advantage of the summer holiday season, the populist government of the Law and Justice (PiS) party pushed through a reform of the judicial system and of the National Council of Judiciary (KRS), a body charged with nominating and promoting judges.

The amendment, widely considered unconstitutional and yet to be signed by president Andrzej Duda (also PiS), would give the government virtually unrestrained control over the body—and therefore much of the judicial system.

That wasn’t all, however.

That same day a new, even more shocking law was introduced. Ostensibly aimed to eliminate corruption and the remnants of the old communist system from the judiciary, the bill amounts to a total purge of all 83 judges in the country’s supreme court, giving the minister of justice, Zbigniew Ziobro, a virtually free rein in appointing their successors.

It was the processing of that draft law—passed by the lower chamber on Thursday and expected to be voted through the Senate by Friday—that sent the country into unprecedented turmoil and, well, madness.

Sparked by a protest at Krasinski Square in Warsaw, the site of the supreme court as well as the recent speech by Donald Trump, a flurry of similar gatherings sprang up all over the country, even in small towns.

The protests, although peaceful, have been described as a “putsch attempt” by the state-run and government-friendly media. Yet it was the Sejm, the parliament, where real mayhem ensued.

The supreme court reform, was immediately fast-tracked in a now familiar pattern of ground-breaking law-breaking legislation, allowing for no prior consultations and without regard for the normal parliamentary procedures.

The debate witnessed unrestrained fury that reached a climax on Tuesday night with a historic speech by Jarosław Kaczyński, Law and Justice’s party chairman, who is the de facto ruler of Poland. Kaczyński, irked by opposition MPs’ quoting his deceased brother, the late President Lech Kaczynski, defending the Supreme Court and independent judiciary, suddenly took the floor and burst out: “I know you’re afraid of the truth, but don’t wipe your treasonous traps with my brother’s name. You destroyed him, you murdered him. You are scoundrels!”

Kaczynski has for years implied indirectly that the main opposition party, Civil Platform (PO, was somehow responsible for his brother’s death in the Smolensk air crash in April 2010 that killed him and many other members of the government. He said as much to one of my fellow journalists in an interview in 2010, but asked the words not be published because “you cannot say such things in public.” So the speech marked a watershed point, a rare, revealing moment of Kaczynski losing his cool.

“Kaczynski revealed that all those reforms are not really about reforming society or the state,” Marek Migalski, a political scientist and a former associate of Kaczynski, tells The Daily Beast. “It is all about a personal vendetta to try and punish those who he thinks wronged him.”

The moment was historic, but the madness did not stop there. Shortly after, amid scuffles and shoving on the parliament’s floor, Kaczynski called Witold Zembaczyński, a member of parliament from another opposition group, the liberal Modern (Nowoczesna) party to his seat to reportedly tell him that every one of PO’s MPs will end up in jail.

The next day did not bring any calm. Kaczynski refused to take back his words, explaining that PO was indeed guilty of his brother’s death because of the criticism and mockery that they used to direct at him. And he was eagerly defended by his party members who went out of his way to be in tune with their leader.

The country’s top diplomat, Foreign Minister Witold Waszczykowski called the speech an “honest and manly response.” Firebrand PiS MP Krystyna Pawłowicz repeated Kaczynski’s “treasonous traps” slur, later adding that she dreams of re-instituting Bereza Kartuska, a pre-war prison camp for political prisoners (this a day after she announced that following its action against the courts the party will go after journalists).

The opposition, for its part, did not avoid provocative behavior either. PO’s Kinga Gajewska also threatened her fellow lawmakers from the governing party, saying they are the one who will be locked up.

Meanwhile, the legislative bulldozer ploughed on. On Wednesday night, when the bill was being considered by the Sejm’s justice committee, the body’s chairman, a former communist prosecutor Stanisław Piotrowicz, shot down hundreds of opposition’s amendments to the draft bill with one stroke, without ever considering them. This prompted another wave of scuffles and chaos.

By the time Thursday’s vote in the lower chamber of parliament was over, where the law was adopted, the opposition were announcing the end of democracy, while the state-run media proclaimed “the end of post-communism.”

But what will all this sound and fury really signify for Poland’s democracy?

It is the latest, and perhaps the most serious step in the ruling party’s campaign to eliminate the constitutional safeguards and the system of checks on its powers. The first such move came at the beginning of PiS’s rule, when the Constitutional Tribunal, the court that rules on constitutionality of laws passed by the parliament, was first paralyzed, and then taken over by PiS through a series of “reforms” and appointment of loyalists to the court.

Marcin Matczak, a professor of law at the University of Warsaw notes that now “government uses it in a way akin to a thief who regularly requests a court to confirm that he has still not stolen anything,” which is what allows the party to go ahead with its purge.

“The question of whether something is constitutional is no longer applicable, since there is no longer a body that everyone agrees can settle the question,” Jacek Sokołowski, a legal expert at Centrum Analiz Klubu Jagiellońskiego, a conservative think-tank, told The Daily Beast. “Besides, it’s like asking whether it is legal to behead a king during the French revolution. It is a revolution, but thankfully it’s a slow-moving revolution, not a bloody one.”

Thus this latest battle is shocking, but not entirely unexpected. It was preceded by relentless coverage in state-run media of the excesses and transgressions of various judges and justices, including alleged corruption and even shoplifting. That only added to the negative opinion of the country’s courts held by many Poles, who are incensed by the length and perceived unfairness of judicial processes.

This is why, Sokołowski argues, a reform of the system is indeed overdue. But the problem is not just the slow pace of the courts.

“Like in the West we’ve had a balance and separation of powers. But unlike in the West the lawyers and the politicians in Poland haven’t learned to cooperate in the creation of public policy. This lack of cooperation resulted for example in stunting the anti-corruption policies of the previous PiS government in 2005-2007,” he says.

The problem is that the reform Poland will get is not the one it needs right now. According to Sokołowski, the result will be a party control of the judiciary without any improvement in efficiency.

Others are even more explicit in spelling out what it means.

“Two words describe what is happening in Poland right now: It’s ‘hybrid dictatorship,’” says Migalski. “We no longer deal with a liberal democracy, but it is not yet a full-fledged dictatorship like that of Putin’s Russia or Erdogan’s Turkey.”

Like many others, Migalski predicts that after the takeover of Constitutional Tribunal, the subjugation of public media, the pacification of civil service, and bringing the courts under party control, next in line are the media, which will be dealt with by the so-called re-polonisation act, which will aim to bring some foreign-owned media (which constitute a big majority in the regional print press and a very significant part of national print and digital media) into Polish hands.

Against this backdrop, the planned purge of the Supreme Court is all the more worrisome because the courts play a key role monitoring elections. And it is the Supreme Court which certifies the fairness and the outcome of the election.

“Democracy differs from authoritarianism in that the rules of elections are certain, while the outcome is uncertain. In a dictatorship it is the other way around. At the moment we are at a point when both the rules and the outcome are uncertain,” says the former PiS politician.

He adds that the nature of the reforms—which in case of a change of the party in power might well be used against PiS—indicates that Kaczyński has decided to try to make the next election, due in 2019, impossible to lose. “We simply no longer can be certain that the next election is going to be democratic,” sums up Migalski.

In effect, there remain very few checks on Kaczynski’s ambitions, but the most unexpected one might prove to be his party colleague, President Andrzej Duda.

When I spoke with one of the PiS politicians ahead of Trump’s visit, the insider said the party’s intention was to strengthen the position of the president. He might now regret that, because buoyed by the success of the visit, Duda, hitherto widely considered a loyal ally and mocked as the chairman’s puppet, stunned everyone on Tuesday when he announced he would not sign the new bill into law unless his own amendments of the KRS reform are implemented.

These amendments stipulate that in order to elect KRS judges the Sejm needs a three-fifths majority, which would prevent the ruling party from singlehandedly picking the judges.

Most legal experts predict this will not change much, however, because, among other reasons, in case of voting stalemate the government’s nominee gets elected by default. Perhaps this is why, despite visible surprise, PiS quickly acquiesced to the president’s demands. Still, this act of independence might show the president intends to play a more independent role in the system.

Perhaps equally unexpected was the size and the breadth of citizen protests, which despite the courts’ unpopularity, have sprung up even in small towns like Dzierżoniów in southwestern Poland, with a population 35,000.

What’s even more surprising is the presence of many young people—the section of the population which contributed the most to PiS electoral victory. This situation might have been completely reversed. The most recent poll by IBRiS shows that a whopping 82 percent of people between ages 19 and 29 consider themselves opponents of the government. The percentage for the whole population of voters is 52 percent.

But the most serious of all checks on PiS authoritarian designs might come not from within, but from the European Union. Ever Since PiS took power in 2015, the question of how to deal with Poland has been an enormous headache for the European Commission.

In January 2016 the commission launched an unprecedented procedure monitoring the rule of law in the country. But the mechanism, intended to deal with the problem before it reached the question of sanctions, went nowhere as Warsaw often ostentatiously ignored Brussels’ concerns.

Faced with the prospect of the new assault on the judicial system, the commission’s vice-president, Frans Timmermans, announced on Wednesday that he is ready to trigger Article 7 of the E.U. Treaty, known as the “nuclear option,” which down the road might mean suspending Poland’s voting rights in the European Council.

However, adopting such harsh punishments is unlikely, because it requires a unanimous vote by all member states. And Hungary’s Prime Minister Viktor Orban, Kaczyński’s closest European ally and an ideological twin, already announced it will block any sanctions against Poland.

“I just don’t see the appetite for such measures among the member states,” says Agata Gostyńska-Jakubowska, an analyst at Centre for European Reform, a London-based think tank. “And it’s not just Hungary. Germany, too, will be reluctant to isolate Poland. So the Commission might well activate Article 7, but it will likely end at that.”

Gostynska notes that the Commission might take a course of action similar to the one it took when Hungary proceeded with its own purge of the judiciary in 2012. The Hungarian government forcibly retired all of the judges over 62 years old. The Commission sued—on the basis of anti-discriminatory regulations—and won. But it did not change the end result, because the judges were not reinstated. They only received compensation.

“In the end it will probably be up to the other member states. They will face a big dilemma,” says Gostyńska-Jakubowska.

And if this continues, and becomes a contagion, democracies everywhere could be threatened by the model that Trump endorsed so enthusiastically in Krasinski Square.