Pro-Democracy protestors. [Courtesy AFP]

China warned Britain on Wednesday that interfering in Hong Kong will backfire after the former colonial power vowed to give sanctuary to locals who may flee the city if a controversial security law is passed.

The United States and Britain have enraged Beijing with their criticism of planned national security legislation that critics fear would destroy the semi-autonomous city's limited freedoms.

British Foreign Secretary Dominic Raab has further angered Beijing by suggesting that it had time to "reconsider" the plan, which could soon be enacted after the proposal was endorsed by China's rubber-stamp parliament last week.

Prime Minister Boris Johnson, meanwhile, said London would not "walk away" from Hong Kongers worried by Beijing's control over the international business hub.

Johnson wrote in a column for The Times newspaper and the South China Morning Post that he would offer millions of Hong Kongers visas and a possible route to UK citizenship if China persists with its national security law.

Chinese foreign ministry spokesman Zhao Lijian said Beijing had lodged "serious representations" with London over Raab's remarks, which "grossly interfered" in Hong Kong's affairs.

"We advise the UK to step back from the brink, abandon their Cold War mentality and colonial mindset, and recognise and respect the fact that Hong Kong has returned" to China, Zhao said at a regular briefing.

Zhao said London must "immediately stop interfering in Hong Kong's affairs and China's internal affairs, or this will definitely backfire."

Hong Kong has been rocked by months of huge and often violent pro-democracy protests over the past year.

In response Beijing has announced plans to introduce a sweeping national security law covering secession, subversion of state power, terrorism and foreign interference.

China says the law -- which will bypass Hong Kong's legislature -- is needed to tackle "terrorism" and "separatism" in a restless city it now regards as a direct national security threat.

But opponents, including many Western nations, fear it will bring mainland-style political oppression to a business hub that was supposedly guaranteed freedoms and autonomy for 50 years after its 1997 handover to China from Britain.

In parliament on Tuesday, Raab said he had reached out to Australia, New Zealand, the United States and Canada about contingency plans if the law creates a deluge of Hong Kongers looking to leave.

"I raised it on the Five Eyes call yesterday -- the possibility of burden sharing if we see a mass exodus from Hong Kong," Raab told lawmakers, referencing the intelligence-sharing alliance between the five powers.

- 'Path to citizenship' -

In his column, Johnson wrote that if China proceeds to justify the "fears" of Hong Kongers, "then Britain could not in good conscience shrug our shoulders and walk away; instead we will honour our obligations and provide an alternative."

About 350,000 people in Hong Kong currently hold British National (Overseas) passports, which allow visa-free access to Britain for up to six months.

Another 2.5 million people would be eligible to apply for one.

Johnson said Britain could allow BN(O) holders to come for a renewable period of 12 months "and be given further immigration rights, including the right to work, which could place them on a route to citizenship".

Britain says it views the proposed law as a breach of the 1984 agreement with Beijing ahead of the handover guaranteeing Hong Kong's freedoms and a level of autonomy -- a deal that formed the bedrock of its rise as a world-class finance centre.

But Zhao said the Sino-British agreement "does not contain a single word or clause that gives the UK any responsibility for Hong Kong after its handover".

Hong Kong Chief Executive Carrie Lam brushed aside international concerns while in Beijing for a meeting with top Chinese officials to discuss the proposed law.

"The international community and some foreign governments have been adopting blatant double standards... in commenting on this matter," said Lam.

"It is within the legitimate jurisdiction of any country to enact laws to protect and safeguard national security. The US is no exception; the UK is no exception."

Lam added that experts and representatives from various sectors of Hong Kong society would be invited to discuss their views in central government-organised seminars on the mainland.

Political tensions are rising in Hong Kong once more.

The city's pro-Beijing weighted legislature is expected to pass on Thursday legislation that would criminalise insults to China's national anthem.

The vote would fall on a day when Hong Kongers will also mark the anniversary of Beijing's 1989 Tiananmen crackdown, despite city authorities banning the traditional annual vigil because of the coronavirus.