In this Aug. 15, 2019 photo, Poland's Prime Minister Mateusz Morawiecki is speaking during national observances of the Armed Forces Day in Katowice, Poland. On Tuesday Morawiecki demanded explanations from the justice minister after allegations surfaced the minister's deputy encouraged an online hate campaign against judges critical of the government. (AP Photo/Czarek Sokolowski)

WARSAW, Poland (AP) — Poland's deputy justice minister resigned Tuesday after allegations surfaced that he encouraged an online hate campaign against judges who were critical of the right-wing government.

Lukasz Piebiak said he was stepping down in the interests of the government, adding that he planned to sue the onet.pl news portal, which published the allegations, for libel.

It was another embarrassment for the nationalist government ahead of the country's Oct. 13 parliamentary election, after the parliament speaker resigned earlier this month amid a scandal over his frequent use of a government jet with his family.

Prime Minister Mateusz Morawiecki said he will accept Piebiak's resignation, adding he believed that would "close the matter." Hours earlier, he had demanded an explanation about the story from Justice Minister Zbigniew Ziobro.

Onet.pl reported that Piebiak encouraged an online user to try to discredit some 20 judges who had been critical of the government, including the head of the independent Iustitia association of judges. It said Piebiak, a judge himself, furnished the online user, identified only as Emilia, with personal data and addresses of the judges, in violation of privacy laws.

Warsaw prosecutors said they have opened an investigation into the allegations.

The portal published what it called a written exchange in which Piebiak assures Emilia of immunity "for doing good things." She offers to disseminate discrediting information about the judges to the state-run media and among judicial circles, moves that Piebiak approved. She also asks for a raise, suggesting she had been doing such work for some time.

Justice Ministry spokesman Jan Kanthak said Ziobro had asked Piebiak to resign. He denied that the online user was employed by the ministry.

The targeted judges had criticized the government for changes it has made to Poland's judiciary, saying they put judges under political control and damaged judicial independence. Piebiak was in charge of the changes, which also prompted European Union leaders to open disciplinary proceedings against Poland's government over possible rule of law violations.

Opposition parties called for Ziobro's resignation as well, saying the revelations compromise him and the whole governing party.

Still, the ruling Law and Justice party is leading in opinion polls by a wide margin, chiefly due to its policy of subsidies for retirees and families with children.