(CNN) Lawmakers in Poland approved a judicial reform bill Friday that will make it easier for the ruling party to appoint a new head of the Supreme Court, despite opposition from civic rights protesters and the European Union.

The legislation, the latest judicial reform proposed by the ruling Law and Justice Party (PiS), was passed in Poland's lower house by 230 votes to 24, with four abstentions. 202 members of parliament, including all 136 from the main opposition party, did not vote.

It comes on the heels of a controversial law mandating that all Supreme Court judges over the age of 65 must retire . That law forced 27 of the 72 judges off the bench, including chief justice Malgorzata Gersdorf, and triggered legal action by the European Commission, the EU's executive arm, amid concern that it would erode judicial independence.

The latest legislation had its first reading in the lower house Thursday, followed by further stormy debate into Friday as the PiS sought to rush through reforms on the last day before the summer recess starts.

On Friday, several hundred protesters gathered outside parliament, shouting "shame" and "Europe, don't abandon us."

The bill will now go for approval to the upper house of parliament, which sits for one more week, and then to the president for ratification.

Among other measures, the law would allow a successor to Gersdorf to be chosen when only two-thirds of the positions on the Supreme Court are filled, rather than requiring almost all positions to be occupied first, as has been the case.

The European Commission announced on July 2 that it had launched an infringement procedure against Warsaw over the law forcing the retirement of judges and gave the Polish government one month to respond. The matter could end up before the European Court of Justice, the bloc's highest court.

The government is keen to push through its latest reforms quickly so that it can appoint a new chief justice without having to have so many new judges in place -- and before the European Union can intervene.

A woman dressed as a Supreme Court judge holds a copy of the Polish constitution during a protest Thursday.

Hundreds of protesters from civic rights and pro-democracy groups rallied outside the parliament building earlier this week as lawmakers debated the draft bill, chanting "Free courts," "Constitution" and "Parliament is ours."

Protester Anna Misia Zielińska told CNN she had attended every protest since December. "I do not have time to wait any more. I do not have time to go back to captivity. I do not have time to waste my time any more," she said.

"I've already lived through communism. It is sad that so few young people are here but they didn't live in the time of communism, they have mobile phones, the internet now, and they are not really aware of what it threatens. And we are threatened with murder."

Another demonstrator, Anna Wielopolska, said she was glad to feel united with those present. "Europe is moving forward and we're backing away," she said.

Critics say that the Polish government is eroding the rule of law and that its so-called reforms are intended to give it control of the judiciary. But Prime Minister Mateusz Morawiecki insisted that the measures are needed because the justice system has not been sufficiently overhauled since the collapse of communism in 1989.

Morawiecki said the bill would help resolve a stalemate over the refusal of the current head of the court to step down.

"A situation has arisen that there are also judges in the Supreme Court involved in the communist past," he told a news conference Thursday. "Today we all know very well what we are talking about, because even the commentators against us emphasize that the facts actually revealed very clearly confirm what we have emphasized."

Morawiecki said the new legislation would help to resolve a stalemate over the refusal of Gersdorf, who is 65, to accept retirement on the grounds that the constitution mandates that she should remain in office until the end of her six-year term, in 2020.

In December, the European Commission warned of a "clear risk of a serious breach in the rule of law" posed by the legal reforms and recommended that the bloc's leaders invoke Article 7 of the Lisbon Treaty.

Under Article 7, the most serious punishment that could be inflicted would be the removal of Poland's voting rights in EU institutions. However, that would require a unanimous vote to be passed and Hungary's right-wing government has already said it would reject the proposal.

Piotr Buras, head of the Warsaw office of the European Council on Foreign Relations, said earlier this month that the EU's decision to launch the infringement procedure had opened the door for the European Court of Justice to prevent the nomination of new judges to the Supreme Court.

In combination with the threat of Article 7 proceedings, it has significantly increased the pressure on Poland's government, he said. The move also signals to other countries such as Hungary that the EU is ready to act in defense of its principles, Buras added.