The Prime Minister offered to make what he said would be one of the "biggest changes" in the history of the British visa system to allow 2.85 million Hong Kong citizens the chance of fully-fledged citizenship.
The move, which represents a dramatic escalation in the stand-off between the UK and China, would put Hongkongers "on the route to citizenship", said the Conservative Party leader.
China's ceremonial legislature, the National People's Congress, endorsed a security law for Hong Kong earlier this week that has strained relations with the UK and the US.
The law will alter the territory's mini-constitution, or Basic Law, to require its government to enforce measures to be decided later by Chinese leaders.
Critics have said the law erodes the "one country, two systems" framework that promised Hong Kong freedoms not found in mainland China for 50 years.
Protesters have taken to the streets in Hong Kong to demonstrate , despite coronavirus social distancing restrictions still being in place.
Mr Johnson said the national security law would breach the treaty between China and the UK and would "dramatically erode" Hong Kong's autonomy.
If China chooses to go ahead with its changes for the island, the PM said he would effectively upgrade the status of British National (Overseas) passports, which 350,000 people in Hong Kong hold and 2.5 million are eligible to apply for, to grant immigration rights beyond the current six month limit.
Writing in The Times, he said: "If China imposes its national security law, the British Government will change our immigration rules and allow any holder of these passports from Hong Kong to come to the UK 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.
"This would amount to one of the biggest changes in our visa system in British history."
Mr Johnson added: "Many people in Hong Kong fear their way of life, which China pledged to uphold, is under threat.
"If China proceeds to justify their fears, then Britain could not in good conscience shrug our shoulders and walk away; instead we will honour our obligations and provide an alternative."
The PM's intervention came just hours after Foreign Secretary Dominic Raab told MPs the UK would look to provide a "pathway to citizenship" for British National (Overseas) passport holders in Hong Kong if China carried out its changes.
Making a statement to the Commons, Mr Raab said the proposed national security law would be a "clear violation" of China's international obligations and would "undermine" existing commitments to protect the rights and the freedoms of the people of Hong Kong, as set out in the Joint Declaration.
Mr Raab warned China that there was still time to "reconsider" its behaviour.
"There is a moment for China to step back from the brink and respect Hong Kong's autonomy and respect China's own international obligations," he said.
But he called for a bigger caucus of opinion to be built up globally to prevent China dismissing efforts to ensure it respects Hong Kong's autonomy from Beijing, arguing the G20 member used "intimidation to get others to stay quiet".
Political pressure is growing across the Commonwealth, with chair of the Commons foreign affairs select committee, Tom Tugendhat, joining his counterparts in Australia, Canada and New Zealand in writing to their national leaders to express concerns over the planned security law.
The jointly signed letter by the committee chairs, which will also be sent to the Secretary General of the United Nations, states that Beijing's imposition is a breach of the legally binding agreement between the UK and China.
The representatives have asked for collaboration to establish a United Nations Special Envoy for Hong Kong.
Mr Tugendhat MP said: "The security law will allow Beijing to launch a complete crackdown on free speech, taking away the voice of the people by preventing any criticism of the Chinese government's ultra-authoritarian rule.
"We cannot allow this to happen."