It may have been China’s biggest unforced error in Hong Kong.

Earlier this year, Hong Kong Chief Executive Carrie Lam, who is close to the government in Beijing, tried to force through a draft bill that would have permitted China to extradite alleged criminals in Hong Kong for trial in mainland China.

The legislation would, in essence, link Hong Kong’s judicial system with China’s, allowing the Chinese Communist Party to seize political dissidents there and effectively ending Hong Kong’s tradition of a free and independent judiciary.

The move was widely perceived as having Beijing’s backing. Chinese Foreign Ministry spokesperson Geng Shuang has stated that China will “continue to firmly support” Lam as she pushed the law. Chinese state-run media also touted it, with the China Daily calling the treaty “long overdue.”

Hongkongers were furious, seeing the move as a naked attempt by China’s leaders to assert more control over Hong Kong, and they took to the streets. The massive protests that have wracked the city for more than two months began with the largest march in Hong Kong history — almost 2 million of the city’s 7 million residents took part.

In the face of near-universal opposition, Lam announced the bill would be suspended, but not scrapped entirely. The hint that the legislation might be renewed when anger died down, combined with incidents of police brutality against peaceful protesters, galvanized hundreds of thousands of Hong Kong residents to continue to protest every weekend for the past eleven weeks. This summer of protest has now become one of the largest protest movements in history.

How did China’s leaders make such a mistake?

The answer has to do with the lessons they learned from crushing the 1989 Tiananmen pro-democracy movement and their subsequent decades of successful repression on the mainland. The ruling Chinese Communist Party has one impulse, and one impulse only: repression.

By pushing this extradition bill, China was trying to apply the same levers of repression to Hong Kong that it uses in the mainland. Only this time, it backfired.

That’s because Chinese party officials fundamentally don’t understand how to effectively govern a free-thinking citizenry. By seeking to quash dissent in an already orderly, prosperous city, the party has turned peace into chaos.

China’s playbook for repression

China’s government has decades of experience in how to crush popular movements. It’s a skill set they’ve honed since June 4, 1989, when they sent in the People’s Liberation Army to open fire on the hundreds of thousands of pro-democracy protesters gathered at Tiananmen Square in Beijing, with official figures placing the number of dead at 300, though estimates range as high as 10,000.

The crackdown ended the period of relatively free intellectual ferment that had characterized the 1980s and ushered in a new era defined by an implicit contract between the Chinese Communist Party and the people: stay silent on politics, and the party will deliver economic prosperity in return. To enforce this political silence, China’s leaders developed a playbook for stopping popular movements before they can ever take hold.

First, the party planted the seeds for a long-term cultural change. They purged hundreds of thousands of reform-minded officials from the party. And in 1992, they instituted a nationwide patriotic education curriculum in schools that played up China’s historic victimization at the hands of foreign powers and presented loyalty to country and party as a primary virtue.

These efforts bore fruit over time. Chinese youth today, unlike their peers 30 years ago, are far less likely to admire democracy or Western-style freedoms, and far more likely to say that one-party rule is a better system for China.

Second, party officials have made it extremely personally risky to participate in protests, a task made far easier by China’s lack of an independent judiciary and the party’s control over domestic security agencies.

Participants may be disappeared and put into “black jails,” or off-books detention centers, beaten up by plainclothes thugs, or formally arrested and charged with “creating a disturbance” or, more seriously, “inciting subversion of state power.” Some have been sent to forced labor prisons. Family members of participants may also be subject to intimidation or detention. Troublemakers can be fired from jobs, removed from leadership positions, and even subjected to torture.

Third, Beijing has sought ever-greater control over the information environment. Media in the People’s Republic has never been free, but in the past decade, ever-stricter media censorship combined with innovative and sweeping internet filters have made it far more difficult for mainland Chinese to access unapproved information.

As messaging apps and social media have become a primary way for people to communicate and for protesters to mobilize, the Chinese government has pioneered new techniques of intercepting messages before they are even sent, crippling the ability of would-be activists to organize.

And fourth, in recent years Chinese leaders have sought to construct a comprehensive surveillance state utilizing facial recognition technology, mass data collection, and artificial intelligence. In some major cities, a network of cameras allow police to immediately identify pedestrians and even drivers. This is done in the name of fighting crime — but of course, that includes political crime. Increasingly, there is no such thing as anonymity and there is nowhere to hide from China’s security state.

It’s important to note, however, that Chinese authorities do actually permit many protests, particularly local demonstrations with modest demands, such as to reroute a proposed road or improve working conditions in a factory. Indeed, there are thousands of such incidents each year. Under some circumstances, officials may even permit larger demonstrations, such as the anti-Japan protests that swept China in 2012 amid a maritime territorial dispute.

But other types of demonstrations are quickly crushed. As China scholars Maura Cunningham and Jeffrey Wasserstrom wrote in Dissent magazine in 2011, “In post-Tiananmen China, not all protests are created equal.” Demonstrations that fit within the party’s historical narrative — that foreign powers victimized China while the Communist Party saved it — are often tolerated, unless they become violent or began to acquire a life of their own, at which point officials view them as threatening and shut them down.

But “when a protest highlights divisions within the Chinese nation,” wrote Cunningham and Wasserstrom, “it almost always draws swift and harsh retaliation from the government.”

The Hong Kong protests are the epitome of such a division. That’s why Beijing is doing everything it can to silence them.

Why China’s repression playbook doesn’t work in Hong Kong

Hongkongers are committing a cardinal sin: turning the party’s preferred historical narrative of victimization by Western colonial powers on its head. For years now, the people of Hong Kong have been fighting to preserve the political legacy left to them by British colonizers, while rejecting what the Chinese Communist Party wants to replace it with.

Britain took control of Hong Kong after defeating the Qing Dynasty in a series of wars in the mid-19th century; a treaty stipulated that the city would remain under British control until 1997. Under the British system, Hong Kong gradually developed strong traditions of judicial independence, freedoms of speech and assembly, and some degree of representative government.

The British did not, however, implement universal suffrage in elections for the city’s top leader, leaving that task to China’s Communist rulers as specified in the 1984 Sino-British Joint Declaration, which laid out the framework for Hong Kong’s 1997 handover back to mainland Chinese sovereignty.

According to that framework, Hong Kong would retain a “high degree of autonomy” until 2047 with explicit protections for the civil liberties its residents had previously enjoyed — giving rise to what came to be known as “one country, two systems.”

It’s no surprise, then, that the Chinese government’s reflex to attempt to deploy the same toolkit of repression in Hong Kong that it has developed to deal with protests on the mainland. But China’s single-minded obsession with stability through repression is counterproductive in a well-functioning region that cherishes political freedom. It was Beijing’s numerous attempts over the past two decades to “mainlandize” Hong Kong that stirred up unrest in the first place.

A primary barrier to Chinese social and political control of Hong Kong is the city’s political system, which protects traditional freedoms such as speech and assembly. Thus, an ongoing goal of China’s has been to recreate the legal conditions present on the mainland.

Since as early as 2003, China has attempted to push through legal changes that would allow authorities to crack down on political freedoms in Hong Kong when desired. That year, Communist Party officials in Beijing pushed Hong Kong’s leaders to introduce a sedition act that would have allowed city officials to ban speech, outlaw organizations, and conduct searches without warrants if there were suspicions of “treason, secession, sedition, subversion against the Central People’s Government.”

But the proposed bill was shelved after Hong Kong erupted in massive protests that filled the streets — the first sign that Hongkongers were not going to simply surrender to the same fate as mainland China.

In 2014, Beijing once again sought to use legal means to assert control over the political system, proposing a legal change that would allow all Hong Kong residents to vote to elect their own leaders, but only from a set of candidates approved by Beijing. Protesters, led by high school and college students, occupied downtown areas to demand that Hong Kong residents be granted the true universal suffrage they had been promised under the Sino-British Joint Declaration.

The disruptive demonstrations that came to be known as the Umbrella Movement polarized the city, pitting powerful pro-China business interests against students and pro-democracy activists. The government, under Beijing’s watchful eye, waited out the movement until it fizzled out. No electoral changes were made; the result was, at best, a draw.

Demoralized, activists were unable to maintain mass interest in their cause, and many observers, including the Chinese Communist Party itself, believed the 2014 movement had been Hong Kong’s last stand.

China’s attempts to subdue Hong Kong through legalized repression gained momentum. An unprecedented cascade of prosecutions followed, with the pro-democracy movement’s top leaders arrested and jailed on dubious charges ranging from contempt of court to conspiracy to cause a public nuisance. And in September 2018, the Hong Kong government banned a small pro-independence party, citing national security reasons — the first time a political party had ever been outlawed there.

That demoralization is likely what emboldened Beijing to think that they would finally be able to achieve their goal of subverting Hong Kong’s independent judiciary, this time through an extradition treaty. This time, however, city residents aren’t nearly as polarized as before.

This time, what’s at stake isn’t just the democratic ideal of free and universal elections, which business interests and other groups have in the past been willing to give up in exchange for economic opportunity on the mainland. High school students, stay-at-home mothers, and wealthy financiers all know that the end of Hong Kong’s judicial independence will mean the end of Hong Kong’s special status and their way of life.

And China’s response in 2014 means that protesters know this may be their last chance. “They know if they give up, the crackdown is going to be worse than what happened after the Umbrella movement,” Victoria Tin-Bor Hui, a professor of political science at the University of Notre Dame, told me.

By attempting to apply mainland-style repression in a city with entrenched political freedoms, the Chinese Communist Party has needlessly alienated an entire generation of Hongkongers.

Bethany Allen-Ebrahimian is a journalist covering China from Washington. She previously covered China and national security for Foreign Policy magazine and the Daily Beast. Follow her on Twitter @BethanyAllenEbr.