Polish MPs on Thursday evening voted 234-211, with nine abstentions, to back the measure, overriding an earlier veto by the upper house of parliament, the Senate, state news agency PAP reported.
The legislation, which critics say could enable politicians to remove dissenting judges, now goes to President Andrzej Duda for signing into law.
Two US Congressmen this month urged the Polish president to uphold his country’s "commitment to democratic values" and reject “dangerous judicial reforms.”
Meanwhile, a Polish government spokesman in December criticised an “off the mark” appeal by the European Union’s executive for politicians in Warsaw to hold off from adopting a law that could see judges punished for questioning legal reforms by the country's ruling conservatives.
Last month protests were held in dozens of cities across Poland by demonstrators critical of the planned legal changes.
Under the legislation, put forward by deputies from the ruling Law and Justice party (PiS), judges could face penalties for challenging the appointment of those of their peers who took up their posts after the conservatives came to power.
Some of the proposals were later modified during parliamentary work.
Polish Prime Minister Mateusz Morawiecki has warned that if judges question the appointment or verdicts of other judges, the Polish justice system could be engulfed by chaos.
Poland's governing Law and Justice (PiS) party, which came to power in late 2015 and won a second term in power in October last year, has argued that broad changes are needed to reform an inefficient and sometimes corrupt judicial system marred by communist holdovers.
The changes have triggered a series of clashes between Warsaw and Brussels.
Poland’s prime minister said last year that some of the legal changes made by his conservative government have met with criticism abroad because they are not understood in Western Europe.