China on Thursday summoned the US ambassador and threatened retaliation 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 signed the legislation under heavy pressure from Congress, where it attracted rare bipartisan support, and in a statement spoke of his "respect" for Chinese President Xi Jinping, calling for both sides to "amicably settle their differences".
But Beijing lashed out furiously, summoning the US ambassador, threatening unspecified "firm countermeasures" and warning Washington not to implement the legislation.
"The nature of this is extremely abominable, and harbours absolutely sinister intentions," the Chinese foreign ministry said in a statement.
"China strongly urges the US side to correct mistakes and change course," the ministry added later.
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.
- 'Timely leverage' -
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.
More than 5,800 people have been arrested and nearly 1,000 charged, with detentions skyrocketing in the last two months.
On Thursday, police entered the campus of the Hong Kong Polytechnic University, to which they have laid siege for days.
Most protesters have now left, some of them arrested and beaten as they tried to flee, and police were collecting evidence including Molotov cocktails and archery bows at the ransacked site.
The violence has done little to dampen public 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 the sale 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".
Later Thursday, pro-democracy activists plan a Thanksgiving-themed rally to honour those who have backed their movement.
- Bipartisan support -
There was speculation Trump could veto the bill to protect his chances of securing a China trade deal as his re-election campaign ramps up.
But he would have faced the possibility of a politically humiliating override -- when two thirds of Congress votes to overturn a presidential veto -- 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."