China has approved a contentious law that would allow authorities to crack down on subversive and secessionist activity in Hong Kong.

The legislation had sparked fears that it would be used to curb opposition voices in the semi-autonomous territory.

Tam Yiu-Chung, Hong Kong’s sole representative to the standing committee of the National People’s Congress, confirmed in an interview with reporters that the law had been passed.

He said punishments would not include the death penalty, but did not elaborate on further details such as whether the law could be applied retroactively.

Mr Tam said: “We hope the law will serve as a deterrent to prevent people from stirring up trouble.

“Don’t let Hong Kong be used as a tool to split the country.”

The South China Morning Post newspaper and public broadcaster RTHK both reported that the standing committee had approved the law unanimously.

Hong Kong leader Carrie Lam had declined to comment earlier in the day, while the committee was still meeting.

She did say that once the law is passed, “the Hong Kong government will announce it and promulgate it for implementation here, and then I and my senior officials will do our best to respond to everyone’s questions, especially regarding the enforcement of this national law”.

The legislation is aimed at curbing subversive, secessionist and terrorist activities, as well as foreign intervention in the city’s affairs.

China Hong Kong Security Law
There are concerns the law would be used to curb opposition voices in the semi-autonomous territory (Andy Wong/AP)

It follows months of anti-government protests that at times descended into violence in Hong Kong last year.

Prominent Hong Kong pro-democracy activist Joshua Wong, as well as Agnes Chow and Nathan Law, issued statements on Facebook indicating that they would withdraw from pro-democracy organisation Demosisto.

Mr Wong said “worrying about life and safety” has become a real issue and that nobody will be able to predict the repercussions of the law, whether that means being extradited to China or facing jail terms of 10 years or more.

More than 100 protesters gathered at a luxury mall in Hong Kong’s Central business district, with several holding up a “Hong Kong Independence” flag as well as posters condemning the national security law.

Police later cordoned off different areas of the mall, including the atrium, detaining and searching several protesters.

The law has met with strong opposition within Hong Kong and condemnation from former colonial ruler the UK, as well as the US, the European Union and others.

Hong Kong China Security Law
A pro-China supporter during a rally to celebrate the approval of a national security law for Hong Kong (AP)

Human rights groups have warned the law could target opposition politicians seen as insufficiently loyal to Beijing for arrest or disqualification from running in September elections for the legislative council.

Ahead of the announcement, the Trump administration said it will bar defence exports to Hong Kong and will soon require licenses for the sale of items to Hong Kong that have both civilian and military uses.

The administration has warned for weeks that if the law was passed, it would take action to end special US trade and commercial preferences Hong Kong had enjoyed since reverting to Chinese rule in 1997.

“The United States is forced to take this action to protect US national security”, US secretary of state Mike Pompeo said in a statement.

“We can no longer distinguish between the export of controlled items to Hong Kong or to mainland China. We cannot risk these items falling into the hands of the People’s Liberation Army, whose primary purpose is to uphold the dictatorship of the (ruling Communist Party) by any means necessary.”

Protesters in Hong Kong
Protesters demonstrate against the new law in a shopping mall (AP)

The US senate unanimously approved a bill last week to impose sanctions on businesses and individuals – including the police – that undermine Hong Kong’s autonomy or restrict freedoms promised to the city’s residents.

The UK said it could offer residency and possible citizenship to around three million of Hong Kong’s 7.5 million people.

China has denounced all such moves as gross interference in its internal affairs.

Foreign ministry spokesman Zhao Lijian said Beijing has decided to retaliate with visa restrictions on “US personnel who perform badly on Hong Kong-related issues.”

Mr Zhao said: “The US side’s attempt to obstruct China from promoting Hong Kong’s national security legislation through the so-called sanctions will never succeed.”

China decided to use the National People’s Congress to enact the legislation after opposition within Hong Kong’s Legislative Council and within society as a whole made it impossible to pass at the local level.

The law is seen as the most significant erosion to date of Hong Kong’s British-style rule of law and high degree of autonomy that China promised Hong Kong would enjoy at least through 2047 under the “one country, two systems” framework.

Passage of the legislation will also allow the central government in Beijing to set up a national security office in Hong Kong to collect and analyse intelligence and deal with criminal cases related to national security.