Donald Trump has signed into law legislation backing pro-democracy protesters in Hong Kong, angering Beijing which has condemned the bill as “full of prejudice and arrogance”.

The legislation, approved unanimously by the US Senate and by all but one lawmaker in the House of Representatives last week, threatens sanctions on Chinese and Hong Kong officials deemed responsible for human rights abuses in Hong Kong. The bill also requires the state department to annually review whether Hong Kong retains enough autonomy to justify favourable US trading terms.

The law, seen as the US backing pro-democracy demonstrators in Hong Kong, further escalates tensions between Beijing and the US whose ties have dramatically deteriorated over the last year amid a protracted trade war.

“This is a pure interference in China’s internal affairs,” China’s ministry of foreign affairs said on Thursday, hours after the bill was signed by Trump. “This bill, which has been denounced by all Chinese people, including Hong Kong compatriots, is full of prejudice and arrogance. It treats Hong Kong with intimidation and threats,” the ministry said in a statement.

“Such an act will make Chinese people, including Hong Kong compatriots, understand the sinister intentions and hegemonic nature of the US,” the ministry added in comments repeated across Chinese state media. “The US plot is doomed to fail.”

Beijing summoned US ambassador Terry Branstad for the second time in a week to demand that Washington stop interfering in China’s internal affairs. China also promised it would retaliate with “firm countermeasures”.

Asked what those countermeasures would be, Geng Shuang, spokesman for the ministry said in a regular press briefing on Thursday: “What is due to come will eventually come”.

Trump also signed a second bill passed by Congress, banning the export to the Hong Kong police of crowd-control munitions, such as teargas, pepper spray, rubber bullets and stun guns.

“I signed these bills out of respect for president Xi, China, and the people of Hong Kong. They are being enacted in the hope that leaders and representatives of China and Hong Kong will be able to amicably settle their differences leading to long term peace and prosperity for all,” Trump said in a statement on Wednesday.

The Hong Kong government said it ‘“strongly opposes and regrets” the legislation and that it would damage the city’s relationship with the US. The Hong Kong government added that the legislation would send the wrong signal to protesters, who the government regards as violent “rioters” pushing the city to the brink of collapse.

Observers worry the signing of the bill will threaten slow-moving negotiations on a trade deal between the US president and China, a priority of Trump’s ahead of his 2020 re-election bid. The president has said the two sides are in the “final throes” of agreeing to the first phase of a trade deal.

Trump had been vague about whether he would sign or veto the legislation, while Beijing demanded he reject the measure, which it called “naked interference” in China’s internal affairs.

In August, Trump referred to the mass street protests as “riots” that were a matter for China to deal with. Trump again referred to “riots” last week, but also called on China to handle the issue humanely.

For the past six months, anti-government protests have posed a serious challenge to Beijing’s authority over Hong Kong, governed by China under a policy known as the “one country, two systems” framework in which the territory is meant to enjoy a “high degree of autonomy”.

Protesters say Beijing and the Hong Kong government have broken the terms of that agreement, struck before the 1997 handover of Hong Kong to Chinese control, and steadily eroded the city’s freedoms.

The protests reached a peak this month with a police siege around a university filled with anti-government demonstrators, many of them students. More than 1,100 people have been arrested in the last week, bringing the total number of arrests since June to more than 5,800.

On Thursday, as the city experienced a rare lull in protests following local elections on Sunday that gave pro-democracy candidates a landslide win, police entered the university to collect evidence and clear dangerous materials like molotov cocktails left by protesters.

The legislation comes amid increasingly vocal criticism of China’s treatment of Uighurs and other predominately Muslim minorities in Xinjiang, following the leak of classified government documents detailing the detention camps.

On Tuesday, US secretary of state Mike Pompeo said: “These reports are consistent with an overwhelming and growing body of evidence that the Chinese Communist Party is committing human rights violations and abuses against individuals in mass detention.”

Many see the US legislation as symbolic, but the bills’ provisions have the potential to upend relations between the United States and Hong Kong and change the territory’s status to that of any other Chinese city.

US Republican senator Marco Rubio applauded 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 in a statement.

Last week, Trump boasted that he alone had prevented Beijing from crushing the demonstrations with a million soldiers, adding that he had told the Chinese president, Xi Jinping, that doing so would have “a tremendous negative impact” on trade talks.

If Trump had opted to use his veto, it could have been overridden by two-thirds votes in both the Senate and the House – easily attainable as measured by the votes in each chamber. The legislation would have automatically become law on 3 December if Trump had opted to do nothing.