Hong Kong's Beijing-backed government said the legislation sent the wrong signal to demonstrators and “clearly interfered” with the city's internal affairs.

China warned the United States on Thursday it would take “firm counter measures” in response to U.S. legislation backing anti-government protesters in Hong Kong, and said attempts to interfere in the Chinese-ruled city were doomed to fail.

U.S. President Donald Trump on Wednesday signed into law congressional legislation which supported the protesters despite angry objections from Beijing, with which he is seeking a deal to end a damaging trade war.

The legislation requires the State Department to certify, at least annually, that Hong Kong retains enough autonomy to justify favourable U.S. trading terms that have helped the territory grow as a world financial center. It also threatens sanctions for human rights violations.

Beijing warned that the United States would shoulder the consequences of China's counter measures if it continued to “act arbitrarily” in regards to Hong Kong, according to a foreign ministry statement.

Hong Kong's Beijing-backed government said the legislation sent the wrong signal to demonstrators and “clearly interfered” with the city's internal affairs.

Anti-government protests have roiled the Chinese-ruled city for six months, at times forcing businesses, government, schools and even the international airport to close.

The financial hub has enjoyed a rare lull in violence over the past week, with local elections on Sunday delivering a landslide victory to pro-democracy candidates.

Hong Kong police entered a sprawling university campus on Thursday at the end of a nearly two-week siege that saw some of the worst clashes between protesters and security forces to have rocked the former British colony.

A team of about 100 plain-clothed police officers entered the city's battered Polytechnic University to collect evidence, removing dangerous items including petrol bombs which remain scattered around the campus.

It was not clear whether any protesters remained on site but officers said any that were found would receive medical treatment first.

Demonstrators in Hong Kong are angry at what they see as Chinese meddling in the freedoms promised to the former British colony when it returned to Chinese rule in 1997.

China denies interfering and says it is committed to the one country, two systems formula put in place at that time and has blamed foreign forces for fomenting unrest.

Polytechnic University on Kowloon peninsula was turned into a battleground in mid-November, when protesters barricaded themselves in and clashed with riot police in a hail of petrol bombs, water cannon and tear gas. About 1,100 people were arrested last week, some while trying to escape.

More than 5,800 people have been arrested since June, the numbers increasing exponentially in October and November, as violence escalated.

Security teams from the university had scoured the maze of buildings at the red-bricked, sprawling campus, a focal point in recent weeks of the citywide anti-government protests that escalated in June, finding no one.

Chow Yat-ming, a senior police officer searching the campus on Thursday said if officers ran into any remaining protesters during the clear out operation “arrests would not be an objective”.