The National People’s Congress approved the bill as it wrapped up an annual session that was held under intensive anti-coronavirus controls.
The measure and the way it is being enacted prompted Washington to announce it no longer will treat Hong Kong as being autonomous from Beijing.
Activists in Hong Kong have complained the law will undermine civil liberties and might be used to suppress political activity.
The legislature also approved a government budget that will increase spending to generate jobs in an effort to reverse an economic slump after Chinese industries were shut down to fight the coronavirus pandemic.