The national security law targets secession, subversion and terrorism with punishments up to life in prison.
Hong Kong was handed back to China from Britain in 1997, but under an agreement supposed to protect certain freedoms for at least 50 years.
But critics say the law is the "end of Hong Kong", and stops those freedoms.
"[China] promised 50 years of freedom to the Hong Kong people, and gave them only 23," US Secretary of State Mike Pompeo said.
The city's leader, however, said the law would "restore stability" after widespread protests in 2019.
"The legislation of the national security law is considered the most important development in relations between the central government and Hong Kong since the handover," said Chief Executive Carrie Lam.
Will there be protests on the anniversary?
A pro-democracy protest is held each year on the anniversary, typically attended by tens or hundreds of thousands of people.
But for the first time since the handover, authorities banned the march - citing a virus ban on gatherings of more than 50 people.
Some activists have pledged to defy the ban and march later in the afternoon.
"We march every year... and we will keep on marching," pro-democracy activist Leung Kwok-hung told Reuters.
But one pro-democracy activist warned there was a "large chance of our being arrested".
"The charges will not be light, please judge for yourself," said Tsang Kin-shing of the League of Social Democrats.
Police officers in the city are on standby, insiders told the South China Morning Post. They said around 4,000 officers were poised to handle any unrest.
What does the new law say?
Under the new law - which applies to both permanent and non-permanent residents - crimes of secession, subversion, terrorism and collusion with foreign forces are punishable by a minimum sentence of three years, with the maximum being life.
Protesters often targeted city infrastructure during the 2019 protests - under the new law, damaging public transport facilities can be considered terrorism.
Beijing will also establish a new security office in Hong Kong, with its own law enforcement personnel - neither of which would come under the local authority's jurisdiction.
Inciting hatred of China's central government and Hong Kong's regional government are now offences under Article 29. BBC