Britain is prepared to offer extended visa rights and a pathway to citizenship for almost 3 million Hong Kong residents in response to China's push to impose national security legislation in the former British colony.

China's rubber-stamp parliament has approved a decision to go forward with national security legislation for Hong Kong that democracy activists, diplomats and some in the business world fear will jeopardize its semiautonomous status and its role as a global financial hub.

Britain, the United States, Australia, Canada and the EU have all sharply criticized the move.

Foreign Minister Dominic Raab said on Thursday that if Beijing went ahead, Britain would extend the rights of 350,000 "British National Overseas" passport holders.

On Friday, the interior ministry said that this policy would apply to all BNOs currently in Hong Kong — a much larger group of around 2.9 million people according to British government figures.

"If China imposes this law, we will explore options to allow British Nationals Overseas to apply for leave to stay in the U.K., including a path to citizenship," Home Secretary Priti Patel said in a statement.

"We will continue to defend the rights and freedoms of the people of Hong Kong."

Beijing says the new legislation, likely to come into force before September, will tackle secession, subversion, terrorism and foreign interference in the city.

Chinese authorities and Hong Kong's government say the legislation poses no threat to the city's autonomy and the interests of foreign investors will be preserved.