Hong Kong has been rocked by a series of crises after the eruption of protests last year over a proposed bill (long since withdrawn) that would have allowed the extradition of some suspects in criminal cases to mainland China.

Hong Kongers who wanted the city promptly to return to peace thought the authorities’ handling of the situation, which dragged on for months and grew more and more violent, was incompetent. For other locals, many outsiders and apparently much of the global media, a people’s legitimate quest for more democracy was being suppressed.

Something had to be done, and the Chinese authorities did it.

The scale and frequency of antigovernment protests has now subsided — thanks to a national security law for Hong Kong promulgated in Beijing on June 30.

Several prominent democracy advocates have since announced their retirement from politics, disbanded their parties or fled the city.

The West tends to glorify these people as defenders of Hong Kong’s freedoms, but they have done great harm to the city by going against its constitutional order and stirring up chaos and disaffection toward our motherland.

Last year’s prolonged unrest dented Hong Kong’s reputation as one of the best places in the world in which to do business. In March, the Heritage Foundation downgraded the city to second place in its Economic Freedom Index for 2020, citing “ongoing political and social turmoil”; Hong Kong had ranked first since 1995.

The Fraser Institute, an independent think tank in Canada, rated Hong Kong as the world’s freest economy in its latest report, but it warned that Beijing’s recent “interventions” would likely hurt the next assessment.

And the Trump administration has imposed sanctions on the city’s chief executive, Carrie Lam, and other senior officials here and on the mainland, and it has revoked Hong Kong’s special trade status with the United States.

Some pundits have already declared the death of “one country, two systems,” the formal arrangement under which Hong Kong is governed by Beijing, though with “a high degree of autonomy” and a commitment to civil rights not available on the mainland.

At the same time, the democratic movement in Hong Kong is in great danger of being hijacked by its more radical faction. In mid-July, ahead of the election for the Legislative Council (LegCo) scheduled for early September, the pro-democracy camp held an informal primary to gauge the public’s support for its various candidates. The ones who advocated uncompromising positions or blanket opposition to the government scored well.

At the end of July, in the midst of an upsurge of coronavirus infections, Mrs. Lam announced that the LegCo election would be postponed for a year because it couldn’t safely be held during the pandemic.

The Hong Kong Bar Association immediately issued a statement challenging the basis, in fact and in law, for the government’s decision, also chiding the administration for inviting Beijing to weigh in, in violation of Hong Kong’s Basic Law, the city’s mini-constitution.

The authorities in Beijing then signaled, by way of a laconic decision of the Standing Committee of the National People’s Congress, that sitting legislators could simply continue doing their work.

But this announcement, too, has proved controversial. At least two of the 24 pro-democracy legislators in LegCo announced this week that they would quit, on grounds that a term extension would breach the Basic Law. Nearly all of the others appear to be keeping their posts, after respondents in an opinion poll favored, by a thin margin, the legislators’ staying over their leaving.

Yet deferring the election, and for a full year, simply was a sound decision.

Another wave of coronavirus infections (which would be Hong Kong’s fourth) could strike later this fall or in the winter, and, say, a six-month deferral might have required another six months’ delay — a move that would confuse the public and no doubt be decried as a lack of foresight on the Hong Kong government’s part.

Some have asked why special arrangements couldn’t be made to hold the election on schedule, when at just the time that the voting was supposed to take place, the government managed to conduct a citywide coronavirus-testing program. The plain answer is that the Electoral Affairs Commission, an independent body, made no recommendations for minimizing health risks to the nearly 4.5 million voters expected to cast ballots on a single day, despite various suggestions from pro-establishment parties to allow for early voting, mail-in voting and voting outside Hong Kong, and to extend voting hours.

Then the coronavirus-detection program itself came under attack.

By the end of the two-week testing drive, on Sept. 14, 1.78 million residents had been screened, about 24 percent of the city’s population. Was this a high level of participation? Or was it low — as some critics claimed, citing that as yet more proof of the community’s lack of trust in the authorities?

Mass testing was the responsible thing to do.

Hong Kong, despite being densely populated and an international business and travel hub, has managed relatively well in fighting Covid-19, without ever mandating a complete lockdown. As of Oct. 1, a total of 5,088 confirmed or probable cases of infection and 105 deaths had been reported, in a city of 7.5 million people.

Yet pro-democracy activists seized on the testing program, too, claiming that the privacy of test-takers’ DNA was at risk, especially since some medical teams administering or analyzing the tests were brought in from the mainland.

The Hong Kong government has not been able to resolve in recent years any of the city’s main challenges, let alone restore public trust or win back hearts and minds. But these problems are not entirely the doing of Mrs. Lam’s government: Previous administrations failed to deal with them in any meaningful way.

This wariness is one reason that the doubts and fears being expressed today about the impact of China’s recent national security law in Hong Kong can only diminish over time, as the new law is tested in court.

For now, despite all the jitters, about 28 people have been arrested under the law. And only one person has been charged — for secession and terrorism: a 23-year-old man accused of driving a motorbike into police officers and displaying a banner that read “Liberate Hong Kong, Revolution of Our Times.” His case is being dealt with in accordance with due process and our criminal laws.

Another story that has garnered much worried attention recently concerns a group of 12 people from Hong Kong who in late August were intercepted by marine police from mainland China for illegally crossing the border while they appeared to be fleeing the city on a speedboat in the direction of Taiwan. At least one of them had been arrested in Hong Kong under the national security law.

All have been in detention on the mainland since — raising concerns among human rights defenders and democracy activists that the fugitives are being held without charge, have been denied bail and refused access to lawyers, and are about to be subjected to the mainland’s legal system, which has fewer protections for defendants than does Hong Kong’s.

But the Hong Kong government has no power to ask any other jurisdiction not to deal with Hong Kong residents in accordance with its own laws simply because those people are from Hong Kong.

To some, the new national security law is especially chilling because it seems simultaneously vague and very severe. But many laws are vague, constructively so. And this one only seems severe precisely because it fills longstanding loopholes — about subversion, secession, local terrorism, collusion with external forces. One person’s “severe” is someone else’s intended effect.

I see little chance of any compromise being reached between the authorities in Beijing and the democratic camp in Hong Kong, be it about the right to elect directly the chief executive or any other major matter. From Beijing’s point of view, democratic development in Hong Kong has brought about nothing but chaos, polarization and anti-China sentiment.

What’s more, Beijing isn’t actually encroaching on Hong Kong’s semi-autonomy by taking measures to proscribe subversive activities in the city. Bear in mind that back in the late 1970s, China’s leader, Deng Xiaoping, put forward the “one country, two systems” formula with a view to bringing Hong Kong, Macau and eventually Taiwan back into the fold. National unity has always been the ultimate objective.

Under the Basic Law, Hong Kong is a special administrative region that enjoys a “high degree of autonomy” — which, by definition, means not complete autonomy, a point I labor to explain to foreign officials and politicians. Any attempt to alter Hong Kong’s formal political status and turn the city into a de facto independent political entity, or to otherwise free it of Beijing’s control, is a fundamental challenge to China’s sovereignty.

Can a few young people clamoring that Hong Kong is its own “nation” really do that much harm? Does simply chanting some feisty slogans or waving a banner that says “independence” — or holding up a blank sheet of paper in its place — really threaten China’s national unity? Maybe, if those statements and gestures indicate a broader engagement in the organizing, planning, participating or committing of actual separatism. Such activities and situations tend to be dynamic, and their effects can quickly metastasize.

Like it or not, Hong Kong is part of China. And given the two’s vast disparity in size and Hong Kong’s growing economic dependence on the mainland, the city’s progressive integration with China is unavoidable.

A realistic goal for Hong Kong ought to be remaining the freest and most international city in China and retaining its unique international status, thanks to the city’s many bilateral agreements with foreign countries and its membership in numerous international organizations.

Foreign governments should not benchmark what happens in Hong Kong against standards that prevail in Western countries; those are governed by a political system entirely different from China’s.

Instead, they should benchmark Hong Kong against the rest of China, and measure how the city can maintain its unique characteristics — openness, a commitment to personal rights and freedoms, respect for the rule of law and the ability to reinvent itself economically. Beijing’s national security law is saving “one country, two systems” by ensuring that Hong Kong does not become a danger to China.