Britain will change its immigration rules and offer millions of people in Hong Kong "a route to citizenship" if China imposes new security laws, Boris Johnson has said.
Writing in the Times, Mr Johnson said the UK would "have no choice" but to uphold its ties with the territory.
China is facing mounting criticism over its planned law.
Many people in Hong Kong fear it could end their unique freedoms, which the rest of China does not have.
The UK is already in talks with allies including the US and Australia about what to do if China imposes the new law - which would make it a crime to undermine Beijing's authority - and people start fleeing Hong Kong.
In the Times on Wednesday, the prime minister confirmed that if China passes the law, people in Hong Kong who hold British National (Overseas) (BNO) passports will be allowed to come to the UK for 12 months without a visa. Currently they are allowed to come for six months.
Around 350,000 people in Hong Kong currently already have a BNO passport, but 2.6 million others are also eligible.
Passport-holders would also be given further immigration rights, including the right to work.
This "could place them on a route to citizenship," Mr Johnson said.
'Britain will not walk away'
The prime minister added that the immigration changes "would amount to one of the biggest changes in our visa system in British history".
"If it proves necessary, the British government will take this step and take it willingly.
"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 last British governor of Hong Kong, Lord Patten, said the offer of support from the UK government was "morally and politically right".
He accused China's ruling Communist Party of employing "bullying" tactics, adding: "Sooner or later with a bully you have to stand up to them, otherwise you'll get knocked about."
Asked whether the UK was entering a new Cold War with China, Lord Patten told the BBC's World at One: "I think we're entering a period of realism with China...
"This is not us against China, it's the way in which the Chinese Communist regime can't stand us, and they've cracked down on Hong Kong because it represents all the things which [President] Xi Jinping dislikes."
Hong Kong is a former British colony. It was handed back to China in 1997.
As part of an agreement signed at the time, it enjoys some freedoms not seen in mainland China - and these are set out in a mini-constitution called the Basic Law.
BNO passports were granted to all Hong Kong citizens born before the Chinese handover in 1997 and while they allow the holder some protection from the UK foreign service they do not currently give the right to live or work in Britain.
There has been widespread international criticism of China's proposed law and the UK government's announcement marks a step up in Britain's opposition to it.
On Tuesday, Foreign Secretary Dominic Raab said the UK was in talks with countries in the Five Eyes alliance about how to handle a potential "exodus" of people from the area.
He urged China to reconsider its plans which, he said, would threaten Hong Kong's autonomy and prosperity.
Senior MPs from Britain, Canada, Australia and New Zealand have urged the United Nations to appoint a special envoy to Hong Kong to monitor how the new law affects human rights.
Earlier this week, seven former UK foreign secretaries urged Mr Johnson to form a global alliance to co-ordinate a response.