People protest during the "Chain of the lights" demonstration against judicial reforms, near the Presidential Palace in Warsaw, Poland, Thursday, Dec. 14, 2017. Some thousands of protesters across Poland demonstrate against proposed new legislation that may give the ruling party control over courts and a key judicial body. (AP Photo/Czarek Sokolowski)

People protest during the "Chain of the lights" demonstration against judicial reforms, near the Presidential Palace in Warsaw, Poland, Thursday, Dec. 14, 2017. Some thousands of protesters across Poland demonstrate against proposed new legislation that may give the ruling party control over courts and a key judicial body. (AP Photo/Czarek Sokolowski)

WARSAW, Poland (AP) — Poland’s senators approved legislation Friday that gives the government greater control of a top court and a key judicial body despite warnings from European Union leaders that the move could put the country at risk of losing its EU voting rights.

The measures affecting appointments, terms in office, and other aspects of the Supreme Court and the National Council of the Judiciary are part of a string of policy changes pursued by Poland’s ruling Law and Justice party that EU officials have said go against the bloc’s fundamental values. The opposition in Poland says they violate the constitution.

ADVERTISEMENT

The laws overwhelmingly endorsed by the Senate still need President Andrzej Duda’s approval, which he is expected to give.

The ruling party argues it needs to reorganize and purge the judiciary because it was never reformed after communism and still harbors vestiges of that era.

Senate Speaker Stanislaw Karczewski said the new legislation is “needed” and he expects the justice system to become more functional soon.

EU officials could trigger a procedure to strip Poland of its voting rights on Wednesday, when they will be reviewing the new legislation to see if it is in line with European standards of the rule of law.

Opposition Civic Platform lawmaker Bogdan Klich said the ruling party’s main aim is to place loyalists at top justice bodies, to control them.

Hours earlier, lawmakers in the lower house of Poland’s parliament, the Sejm, passed equally much-criticized new rules for local elections that opponents claimed will undermine the independence of electoral bodies and fair elections.

Opposition Modern party leader, Katarzyna Lubnauer, said their adoption would mean the “demise of what we call democracy.”

The head of the State Electoral Commission, Wojciech Hermelinski, said Friday he will seek a meeting with the president to share his skepticism. Duda and the Senate still need to approve the regulations, but could also question or reject them.

Under the new rules, lawmakers would choose seven out of nine commission members, who are currently chosen by judges. The interior minister would be given authority to appoint election supervisors.

Rules governing the validity of ballots also would be liberalized by allowing voters to correct their choices on the spot. Critics say that opens the door to manipulation.

A few hundred protesters in front of parliament building were protesting the new bills and calling on Duda to veto them.