Thousands of protesters in Hong Kong, some draped in American flags, have staged a “Thanksgiving” rally in the heart of the city after the approval by Donald Trump of human rights legislation aimed at protecting them.

“The rationale for us having this rally is to show our gratitude and thank the US Congress and also president Trump for passing the bill,” said 23-year-old Sunny Cheung, a member of the student group that lobbied for the legislation.

“We are really grateful about that and we really appreciate the effort made by Americans who support Hong Kong, who stand with Hong Kong, who do not choose to side with Beijing,” he said, urging other countries to pass similar legislation.

The law requires the state department to certify, at least annually, that Hong Kong is autonomous enough to justify favourable US trading terms that have helped it become a world financial centre. It also threatens sanctions for human rights violations.

Organisers of the rally put together a list of possible officials to sanction, including Hong Kong’s leader, chief executive Carrie Lam Cheng, former police chiefs Andy Tsang and Stephen Lo, the heads of the Chinese liaison office Wang Zhimin and secretary for justice Teresa Cheng who has alleged she was attacked and injured by protesters in London.

Hong Kong has faced almost six months of intense political unrest over the growing influence of Beijing in the former British colony, meant to enjoy a “high degree of autonomy” under the terms of its 1997 handover to China.

The conflict, which reached a peak in the last few weeks during a police siege of a university, has worsened already tense ties between the China and the US, which Beijing claims has had a “black hand” in instigating the anti-government protests.

The Chinese foreign ministry has said the US would shoulder the consequences of China’s countermeasures if it continued to “act arbitrarily” in regards to Hong Kong.

China is considering barring the drafters of the legislation, whose US Senate sponsor is Florida Republican Marco Rubio, from entering mainland China as well as Hong Kong and Macau, Hu Xijin, the editor of China’s Global Times tabloid, said on Twitter.

Protesters hold posters of US president Donald Trump during a Thanksgiving Day rally. Photograph: Chris McGrath/Getty Images

Chinese vice foreign minister Le Yucheng summoned US ambassador Terry Branstad on Thursday and demanded that Washington immediately stop interfering in China’s domestic affairs. 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 Chinese foreign ministry said. “The US plot is doomed.”

The foreign ministry spokesman, Geng Shuang, declined to comment on any countermeasures planned by Beijing. “You better stay tuned, and follow up on this,” he said. “What will come will come.”

Gao Feng, a spokesman for China’s commerce ministry, did not comment directly on whether the law would affect trade talks, saying there were no new details of their progress to disclose.

While protesters were gathering in Hong Kong on Thursday night, Chinese state media addressed recent challenges to Beijing’s authority, including the landslide win for pro-democracy candidates at local elections on Sunday, the passage of the bill in the US, as well as recent leaks of classified documents that contradict China’s defence of its policies in Xinjiang.

“All of this has made mainland Chinese feel unwell but this is the price we have to pay for China’s rise … most of the pressure from the US and other western countries is like spittle to us. Xinjiang and Tibet fit into this category. We must fight back but we must also be very clear that these attacks won’t stop us,” an editorial from the Global Times said.

Thousands of Hong Kong citizens gathered in Central to celebrate the US human rights bill. Photograph: Liau Chung-ren/ZUMA Wire/REX/Shutterstock

It added, in response to growing chorus of criticism from other countries in the past week over the mass detention of Muslim minorities in Xinjiang : “As long as Xinjiang has achieved peace and prosperity, what the outside world says is really of second priority.”

Prominent democracy activists Joshua Wong and Denise Ho addressed the rally, thanking frontline protesters for the passage of the bill. Crowds sang the protest anthem “Glory to Hong Kong”, waving their phone torches.

Several hundred people also gathered outside the Polytechnic University, which police entered after a nearly two-week siege.

“The situation in Poly U is still a disaster,” said 30-year-old Ng, dressed in black and wearing a surgical mask. “We are out to show we will never forget the Poly U incident.”

Hong Kong police on Friday were preparing to clear the university, where more than 1,000 protesters had been holed up after a day-long clash between demonstrators and police on 17 November. The number of protesters remaining has dwindled and police say that none remain.

Police, who said the police cordon around the campus would soon be lifted, have found almost 4,000 Molotov cocktails, corrosive chemicals including acid, as well as 12 bows and 200 arrows and an air rifle.

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

The city on Friday was bracing for protests, announced by demonstrators on social media, over the weekend and into next week. The Civil Human Rights Front, a group that organised million-strong marches in June, has called for a rally on 8 December, which will be seen as a test of support for the protests as they enter their seventh month.

The protests have hit the Asian financial hub’s economy, especially tourism and business travel to the city. Hong Kong carrier Cathay Pacific Airways as well as South African Airways and Malaysia’s AirAsia have cut flights to and from Hong Kong. Hong Kong’s Civil Aviation said airlines would still be able to keep their airport slots.