China has warned the United States it would take "firm counter measures" in response to US legislation backing anti-government protesters in Hong Kong, and said attempts to interfere in the Chinese-ruled city were doomed to fail.

US President Donald Trump yesterday 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 is autonomous enough to justify favourable US trading terms that have helped the territory grow as a world financial centre.

It also threatens sanctions for human rights violations.

Beijing warned that the US 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.

Chinese Vice Foreign Minister Le Yucheng also summoned US Ambassador Terry Branstad today and demanded that Washington immediately stop interfering in China's domestic affairs, and stop causing further damage to bilateral relations.

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

"This so-called legislation will only strengthen the resolve of the Chinese people, including the Hong Kong people, and raise awareness of the sinister intentions and hegemonic nature of the US. The US plot is doomed," the Chinese foreign ministry statement said.

Anti-government protests have been ongoing in the 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 the Polytechnic University today at the end of a nearly two-week siege that saw some of the worst clashes between protesters and security forces.

It was unclear whether any protesters remained at the site as a team of about 100 plain-clothed police moved into the sprawling campus to collect evidence and remove dangerous items such as petrol bombs.

Police said any protesters found would receive medical treatment and arrests were not a priority.

The university became 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.

Witnesses at the university said rubbish and abandoned gear including sleeping bags, helmets and gas masks were strewn everywhere, but no protesters could be seen.

More than 5,800 people have been arrested since the unrest broke out in June over a proposal to allow extraditions to mainland China, the numbers increasing exponentially in October and November as violence escalated.

Demonstrators are angry at police violence and what they see as Chinese meddling in the freedoms promised to the former British colony when it returned to Chinese rule in 1997, such as an independent judiciary.

China says it is committed to the "one country, two systems" formula put in place at the handover and has blamed foreign forces for fomenting the unrest, an allegation repeated in response to the US law.