HONG KONG -- Beijing's top official in Hong Kong on Thursday warned foreign forces not to interfere with the "bottom line" of national security in the city, threatening retaliation amid tensions between China and Western powers.

The U.S., Britain and their allies have condemned China's tightening control over Hong Kong's freedoms, including the sweeping national security law and electoral reforms that have all but silenced the once-vibrant opposition in the semi-autonomous territory.

"When it is time, actions must be taken in relation to any external or foreign forces that may interfere Hong Kong affairs or attempts to use Hong Kong as a pawn," said Luo Huining, director of the central government's liaison office in Hong Kong.

"We will propose strong objections and teach them a lesson," he said at the opening ceremony for Hong Kong's National Security Education Day.

Authorities marked the event with a police college open house, where police personnel demonstrated the Chinese military's goose step march, replacing British-style foot drills from the time Hong Kong was ruled by the U.K. until the 1997 handover to China.

Critics say Beijing's crackdown -- aimed at reining in dissent after months of anti-government protests in 2019 -- has eroded freedoms promised to Hong Kong when it returned to China's rule. Most of the city's prominent pro-democracy activists and advocates are currently facing charges, are in jail or have fled abroad.

During his speech, Luo said that everyone in Hong Kong needs to respect the legal responsibility of upholding national security in the city.

"Anyone who wants to go beyond the bottom line of national security, and people's livelihood, the central authorities will never allow such acts."

Hong Kong's leader Carrie Lam described the 2019 protests, which sometimes erupted in violence, as "almost like terrorist activities." She also called efforts by those advocating Hong Kong's independence and self-determination a huge safety risk as the goal was to snatch power from the government.

"If this is not stopped, then national sovereignty, security, development interests will be affected. So this is an unprecedented crisis," she said. "The National Security Law in Hong Kong immediately restored stability in society."

Lam also said that public officers in Hong Kong have an important responsibility in safeguarding national security.

In schools, students were encouraged to take part in activities including "national security" mosaic walls with photos of students' faces, to teach that people should work collectively to protect their homeland.

Authorities also encouraged schools to hold flag raising ceremonies, play the national anthem and distributed brochures that stress the importance of national security.