HONG KONG -- British Prime Minister Boris Johnson said the United Kingdom stands ready to open the door to almost 3 million Hong Kong citizens, as the city's leader arrived in Beijing on Wednesday for meetings on a planned national security law that has many worried about their future.

Johnson said in a column published online by the South China Morning Post, a Hong Kong newspaper, that the security law would curtail freedoms in Hong Kong and conflict with China's obligations under its agreement with the United Kingdom when it took back the former British colony in 1997.

"Many people in Hong Kong fear their way of life -- which China pledged to uphold -- is under threat," he wrote. "If China proceeds to justify their fears, then Britain could not in good conscience shrug our shoulders and walk away."

China shocked many of Hong Kong's 7.5 million people when it announced earlier this month that it will enact a national security law for the city, which was promised a high level of autonomy outside of foreign and defence affairs.

In Beijing, foreign ministry spokesperson Zhao Lijian reiterated China's stance that the agreement with the U.K., known as the Sino-British Joint Declaration, was essentially null and void.

"The U.K. has had no sovereignty, governance or supervision over Hong Kong since its return (to Chinese rule)," Zhao said at a daily briefing.

"Therefore, the British side has no right to cite the Sino-British Joint Declaration to make irresponsible remarks on Hong Kong affairs and interfere in China's internal affairs," Zhao said.

Hong Kong leader Carrie Lam arrived in Beijing on Wednesday for meetings with central government officials about the planned law, which she supports. China could enact the law later this month or at the end of August, analysts have said.

About 350,000 Hong Kong citizens hold British National Overseas passports, a legacy of the colonial era, and 2.5 million others are eligible to apply for them, Johnson said in his column. Long lines have formed at DHL courier offices in the city since the announcement as people rush to apply for or renew their BNO passports.

Johnson, echoing earlier statements by Cabinet ministers, said that if China imposes a national security law, Britain would allow holders of the BNO passports to remain for 12 months on a renewable basis and would grant them the right to work, placing them on a possible path to U.K. citizenship.

"This would amount to one of the biggest changes in our visa system in British history," Johnson wrote, adding, "I hope it will not come to this."

BNO passport holders currently can stay in the U.K. for only up to six months.

Separately on Wednesday, Hong Kong pro-democracy activist Joshua Wong called on leaders in Europe to oppose the national security law, saying it erodes the "one country, two systems" framework promised to the semi-autonomous Chinese territory.

Wong said that after U.S. President Donald Trump threatened to impose sanctions on Hong Kong last week, the momentum should be kept to build a "global alliance to stand with Hong Kong."