Hungary's Prime Minister Viktor Orban has vowed to defend Poland from criticism from the EU after it approved controversial court reforms.
Hungary will use "all possible legal means in the European Union to show solidarity with the Poles", he said.
Earlier, Poland's Senate backed a bill that gives MPs and the justice minister the power to appoint judges.
The ruling Law and Justice Party says this will fight corruption. Critics say it will destroy judicial independence.
Thousands of protesters have taken to the streets in recent weeks to oppose the bill, which will see all Supreme Court judges removed and replaced.
Poland's President, Andrzej Duda, will decide whether or not judges - who will be forced into retirement - can have their jobs back.
Speaking at a gathering in Romania, Mr Orban attacked critics, saying: "In the interest of Europe and in the spirit of the old Hungarian-Polish friendship, the inquisition campaign against Poland can never lead to success."
The Polish government says the changes will make the judiciary more effective and ensure that judges are accountable.
However, European Council President and former Polish Prime Minister Donald Tusk has condemned the move as "backward".
"Bringing the courts under the control of the governing party in the manner proposed by the Law and Justice Party will ruin the already tarnished public opinion about Polish democracy", he said in a statement.
The European Commission's Vice-President, Frans Timmermans, has threatened to withdraw Poland's voting rights in EU meetings if Warsaw does not suspend the reform.
Now the legislation has passed in the Senate, the bill will go to President Duda, an ally of the Law and Justice Party, for final approval.
On Friday, the United States urged the Polish government to ensure that any changes respect the country's constitution.
"The Polish government has continued to pursue legislation that appears to undermine judicial independence and weaken the rule of law in Poland," the US Department of State said in a statement.
"Poland is a close ally of the United States, and a strong and healthy democracy in Poland is vital to relations between our two countries."