The Polish president has vetoed a media ownership law that critics said was aimed at silencing the US-owned news channel TVN24, side-stepping a row with Washington as tensions rise in eastern Europe amid what some countries see as increased Russian assertiveness.

“I am vetoing it,” Andrzej Duda said in a televised statement, after the EU and the US heavily criticised the law.

The law would have prevented companies outside the European Economic Area from holding a controlling stake in Polish media companies. That would have forced the US group Discovery to sell its majority stake in TVN, one of Poland’s biggest private TV networks. TVN24 is its news channel.

The US charge d’affaires in Warsaw, Bix Aliu, thanked Duda “for his leadership and commitment to common democratic values and for protecting the investment climate in Poland”.

“Allies are stronger together!” he said.

TVN’s board of directors in a statement welcomed the announcement “with appreciation and joy”, saying the president had “stood up for good relations with the US”.

While the move allows Nato-member Poland to avoid a potentially explosive row with Washington the decision means that a project voted through parliament by the ruling nationalist Law and Justice party (PiS) has been blocked by a president elected as their ally.

Polish lawmakers adopted the law this month and the government had argued the law would protect Poland’s media landscape from potentially hostile actors such as Russia.

Duda said he agreed with this principle, but that it should not be made to apply to existing business arrangements and investment treaties.

Thousands of Polish people protested earlier this month outside the presidential palace in Warsaw against the law, with many in the crowd waving EU flags and chanting “free media”.

The former president of the European council, Donald Tusk, who leads the opposition Civic Platform party, said Duda’s decision showed that “pressure makes sense”.

The European Commission spokesperson Christian Wigand had said before Tusk’s veto that the proposed legislation would pose “severe risks to media freedom and pluralism in Poland”.

Poland’s ruling Law and Justice (PiS) party controls the public television broadcaster TVP, which has become a government mouthpiece, and much of the regional press.

Since PiS was elected to power in 2015, Poland has dropped 46 places in Reporters Without Borders’ world press freedom index to reach the 64th position.

Duda said in a televised statement on Monday that if the law came into force it could violate a treaty signed with the United States on economic and trade relations.

“One of the arguments considered during the analyses of this law was the issue of an international agreement that was concluded in 1990 ... this treaty speaks about the protection of investments,” he said.

“There is a clause which says that media-related investments may be excluded, but it concerns future investments.”

PiS lawmaker Joanna Lichocka told public broadcaster Polskie Radio 24 it was “surprising” Duda had not referred to loopholes in the law regarding foreign ownership of media companies in the justification of his decision.

“I would not see it in terms of a betrayal, but a difference in approach to what is right for the Republic of Poland,” she said.