The US is backing protesters in Hong Kong despite angry objections from China. (File)

China warned Thursday that it was ready to take "firm countermeasures" against the United States after President Donald Trump signed a law supporting pro-democracy protesters in Hong Kong.

"The nature of this is extremely abominable, and harbours absolutely sinister intentions," the foreign ministry said in a statement, without specifying what measures Beijing might take.

Trump signed the law on Wednesday, after it received almost unanimous US congressional support.

In a statement, he spoke of "respect" for Chinese President Xi Jinping and said he hoped the "leaders and representatives of China and Hong Kong will be able to amicably settle their differences".

But the move provoked fury from Beijing, which called it an "an act of undisguised hegemony".

"(It) seriously violated international law and the basic norms of international relations," the foreign ministry statement said, accusing the US of supporting the "endangerment of social order by violent criminals" and seeking to destroy the stability of Hong Kong.

"We advise the US not to obstinately go its own way, otherwise China will take firm countermeasures, and the US side must bear all the ensuing consequences."

The Hong Kong Human Rights and Democracy Act requires the US president to annually review the city's favourable trade status and threatens to revoke it if the semi-autonomous territory's freedoms are quashed.

Congress also passed legislation banning sales of tear gas, rubber bullets and other equipment used by Hong Kong security forces in putting down the protests, which are now in their sixth month.