China on Thursday threatened to retaliate after US President Donald Trump signed legislation supporting Hong Kong pro-democracy protesters, just as the world's top two economies edge towards a trade truce.
Trump had seemed reluctant to sign the legislation, but came under heavy pressure from Congress, where the issue has attracted rare bipartisan support.
In a statement, Trump 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 Beijing reacted furiously, warning it was ready to take unspecified "firm countermeasures".
"The nature of this is extremely abominable, and harbours absolutely sinister intentions," the Chinese foreign ministry said in a statement.
In Hong Kong, the government expressed "extreme regret" after Trump signed legislation requiring an annual review of freedoms in Hong Kong and banning the sale of crowd control equipment like tear gas.
"The two acts are obviously interfering in Hong Kong's internal affairs," the city government said in a statement, warning the move would "send the wrong message to the protesters".
And Beijing's liaison office in the city condemned Washington's "disgusting conduct", saying it would bring "trouble and chaos" to Hong Kong.
Hong Kongers have protested in huge numbers over the last six months, fuelled by years of growing fears that authoritarian China is stamping out the city's liberties.
The territory's Beijing-backed leaders have offered few concessions and police have cracked down hard on protesters in increasingly violent confrontations.
On Thursday, police entered the campus of the Hong Kong Polytechnic University, where they lay siege to protesters inside for days.
Most protesters have now left, some of them arrested as they tried to flee, and police were collecting evidence including Molotov cocktails at the ransacked site.
The violence has done little to dampen support though, with pro-democracy candidates winning a landslide victory in local council elections over the weekend.
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.
Trump also signed legislation banning sales of tear gas, rubber bullets and other equipment used by Hong Kong security forces in putting down the protests.
Republican Senators Marco Rubio and Jim Risch, together with Democratic Senators Ben Cardin Bob Menendez, issued a joint statement welcoming Trump's decision.
"The US now has new and meaningful tools to deter further influence and interference from Beijing into Hong Kong's internal affairs," Rubio said.
Hong Kong activists said the move would help build international support for their movement.
Sunny Cheung, a student who testified before Congress in support of the legislation, told AFP it would give "Hong Kong people timely leverage to press Hong Kong and Beijing further on democratic reform".
Trump could have vetoed the bill, particularly with a long-awaited China trade deal reportedly near -- a key goal for the president as his reelection campaign gets underway.
But he would have faced the possibility of a politically humiliating override, with pressure only mounting after Sunday's decisive local election victory for pro-democracy candidates.
His decision was welcomed even by his fiercest domestic opponents.
"This bicameral, bipartisan law reaffirms our nation's commitment to democracy, human rights and the rule of law in the face of Beijing's crackdown," Democratic House Speaker Nancy Pelosi said in a statement.
"I am pleased that the president signed this legislation and look forward to its prompt enforcement."
On Tuesday, Trump said he was "with" the protesters, but quickly backpedalled, emphasising his close ties to Xi and efforts to secure a long-delayed resolution to the trade war.
"It's going very well but at the same time we want to see it go well in Hong Kong," he said.
"I think it will. I think that President Xi can make that happen. I know him and I know he'd like to make it happen."
Do not miss out on the latest news. Join the Standard Digital Telegram channel HERE.