WARSAW, Poland - Poland’s president has signed a bill earmarking nearly 2 billion zlotys ($510 million) to fund public television and radio, broadcast outlets that have become mouthpieces for the country’s right-wing government and given the president positive coverage as he campaigns for reelection.

President Andrzej Duda, who hails from the ruling Law and Justice party, signed the funding bill late Friday as he campaigns for a second five-year term in a May election.

His decision was closely watched given how politically charged the issue of public media has become in Poland. The political opposition had called for the money to instead be used for cancer treatment.

Duda said he had serious reservations about the legislation because of the way it distributes funds regionally and between radio and TV, but ultimately chose to support it. In doing so, he allowed a large injection of money to go into broadcasters that were already helping his campaign.

Prime Minister Mateusz Morawiecki recently dismissed the argument that the money should have instead gone to cancer treatment, saying that 11 billion zlotys was earmarked for that purpose this year and has not been spent.

More generally, the Polish government defends the state media, arguing that the perspectives they air are necessary to counterbalance what it views as extreme anti-government bias in the private media.

Putting the measure over its final hurdle with his signature was expected to hurt Duda with centrist voters given the reputation of Poland’s public media in recent years. The Law and Justice party uses public television station TVP to praise the government’s achievements and to sully the standing of political opponents. Older Poles critical of the government often liken the current practice to the propaganda of the communist era.

The mayor of Gdansk, Pawel Adamowicz, was killed at a public charity event last year after being the subject of months of negative coverage by TVP. Opponents of the ruling party accused the broadcaster of waging a hate campaign against Adadowicz before an ex-convict killed the mayor. Protests at TVP’s headquarters folowed the mayor’s death.

The government’s use of public media — which by statute are supposed to be neutral — has caused Poland to fall in global free media rankings.

Reporters Without Borders called Poland’s public media “government propaganda mouthpieces.“ Directors of the entities ”tolerate neither opposition nor neutrality from employees and fire those who refuse to comply,” according to the advocacy group.

The legislation earmarking more money for the broadcasters was needed to cover the gap left by a fall in revenue from licensing fees, which by law Poles are supposed to pay to use TV and radio but in practice often do not.