Poland is locked in constitutional crisis after the ruling conservatives appointed five judges to the highest judicial body in a move the opposition said was illegal.
Opposition politicians and liberal media accused the government, which made the appointments during an evening parliament session on Wednesday, of seeking to take charge of democratic institutions in Poland.
One parliament member said the ruling Law and Justice party (PiS) was emulating Hungary's nationalist Prime Minister Victor Orban, who has repeatedly challenged Brussels with nationalist policies from raising taxes on foreign banks to challenging the EU's handling of the migrant crisis.
But PiS, which swept into power in an October election on a wave of nationalist sentiment, has said judges in the Constitutional Court need to be replaced to reflect the new balance of power.
"We are introducing a constitutional order in Poland," PiS lawmaker Stanislaw Piotrowicz said in a debate preceding the Wednesday vote. "The Constitutional Court has been recently acting at PO's behest," he said referring to the former ruling party.
The stakes are high. Gaining control of the Constitutional Court could make it easier for PiS to overhaul Poland's retirement system and curb foreign ownership of banking and media, the party's flagship policy plans.
"This is a disgrace for parliament and for parliamentary democracy," Grzegorz Schetyna, foreign minister in the previous centrist government, told reporters after Wednesday's vote.
Five judges had been nominated by the previous government and a leftist opposition grouping before the Oct. 25 election.
But President Andrzej Duda, a close ally of PiS, failed to swear them in, opening the way for PiS to challenge their candidacies.
Duda swore in several of the new judges after Wednesday's vote in a midnight ceremony.
In a further twist, the Constitutional Court ruled on Thursday the previous government had the right to nominate three but not five of the judges it had picked earlier this year. It was not immediately clear how this would affect Wednesday's nominations.
PiS accuses the former government, formed by the center-right Civic Platform (PO), of breaking the law when it passed a bill earlier this year allowing it to appoint five judges instead of the three it had been scheduled to elect in
the 15-seat tribunal.
"PO clearly breached the constitution," government spokeswoman Elzbieta Witek said. "PiS is trying to fix what PO broke."
The opposition says it will challenge Wednesday's nominations in the Constitutional Court. A protracted fight could hurt Poland's image as a model of post-communist transition.
PiS says corrupt and inefficient state institutions are failing to ensure post-communist prosperity is shared fairly.
"I am here to speak for my entire generation," said a 32-year-old government supporter, Magdalena Piejko, one of several dozen people demonstrating in front of parliament on Wednesday.
"We are against the establishment which is preventing good change in Poland. People have voted for change and it seems we need to fight for it," she said.
Since taking power, PiS has replaced the heads of all intelligence agencies and denied opposition lawmakers access to a rotating chairmanship on the legislature's intelligence panel.
It also plans to give the justice minister direct control over prosecutors.
In Hungary, Orban has taxed banks and other foreign businesses to finance income tax cuts and family benefits, moves which PiS is now looking to replicate.
Orban has also curbed the jurisdiction of the top Constitutional Court and ensured that loyalists dominate public institutions, including the central bank.
"It took Hungary more than a year to implement this scenario. Here it is being implemented in 12 days," Schetyna said.