image sourceReutersimage captionProtesters demonstrated against the proposals on Tuesday

Poland's parliament has passed a new media bill that opponents say is an attempt to silence a TV channel critical of the government.

The government says the law is needed to stop hostile foreign powers taking control of its broadcasters.

But critics say it is an attempt to push US company Discovery to sell the country's biggest TV network, TVN.

The law threatens to sour relations with the US, a key ally, and deepen EU concern over media freedom in Poland.

Thousands of demonstrators took to the streets across Poland on Tuesday to express their anger at the proposals.

A crowd gathered outside the parliament in Warsaw, and rallies were held in Krakow, Wroclaw, Poznan, Lublin and Szczecin.

  • Poland becoming an authoritarian state – top judge
  • Why Poles want more of this man's populist message

The government has argued that existing rules banning companies based outside the European Economic Area from directly owning broadcasters should be tightened to prevent Chinese and Russian firms from controlling Polish media outlets.

However, the plans have been criticised by the US, which is an important military ally. The US company Discovery owns TVN through a subsidiary based in the Netherlands.

Wednesday's much-anticipated vote was due in the afternoon but briefly postponed as opposition MPs tried to adjourn the session.

Poland's coalition government was thrown into disarray after the prime minister sacked his deputy on Tuesday. Former Deputy PM Jaroslaw Gowin – who opposes the law change – leads a junior partner in the United Right coalition that has ruled since 2015.

The government said Mr Gowin had "undermined confidence" in its actions.

His party, Agreement, had been increasingly at odds with its senior coalition partner, Prime Minister Mateusz Morawiecki's Law and Justice (PiS) party, and has now voted to quit the coalition.

The loss of Agreement's 13 MPs means the coalition will no longer command a majority in the lower house of parliament.

The bill will now pass to the opposition-controlled Senate, which may make amendments or reject the bill, the BBC's Warsaw correspondent Adam Easton says.

However, the lower house of parliament can overturn any changes and finally approve the bill.