Hong Kong is an inalienable part of China, said the local government spokesman in reaction to US President Donald Trump’s statement on new security law.

In a statement carried by Xinhua news, Hong Kong Special Administrative Region (HKSAR) spokesman expressed “deep regret” that the US government continued to “smear and demonize the legitimate rights” and duty of China towards Hong Kong.

“Hong Kong is an inalienable part of China and any suggestion that China does not have the right to protect its own territory from separatists, terror and anarchy does not stand up to scrutiny and smacks of hypocrisy and double standards,” the local government spokesman said adding that the new national security law in the HKSAR is aimed at “restoring stability” to Hong Kong society.

Trump last Friday ordered his administration to halt Hong Kong's preferential treatment under US law in retaliation for China's decision to apply a national security law to the semi-autonomous territory.

"I am directing my administration to begin the process of eliminating policy exemptions that give Hong Kong different and special treatment," Trump told reporters in the Rose Garden, noting the directive will span all bilateral agreements with Hong Kong from trade to extradition.

"We will take action to revoke Hong Kong’s preferential treatment as a separate customs and travel territory from the rest of China," he added.

China's National People's Congress, the country's top legislative body, formally passed the Hong Kong security legislation on Thursday. Activists fear it will be used by Beijing to quash dissent in the territory.

Hong Kong, a semi-autonomous region under China since 1997, last year witnessed months of protests against a move to legalize extradition to mainland China.

Trump said that Beijing, by instituting the controversial law, "unilaterally imposed control over Hong Kong’s security."

“To allege that the improved legal system and enforcement mechanisms targeting an extremely small minority of criminals to be introduced by the national security law is undermining Hong Kong people's freedoms is simply fallacious,” Hong Kong government spokesman said.

“Every country has legislation in place to safeguard national security, including the US.”

The Hong Kong government said the new legislation “only targets acts and activities endangering national security”.

“The five basic principles of the legislation are firmly safeguarding national security, upholding and improving the one country, two systems,” the statement added.