Up to 2 million people have taken to the streets of Hong Kong to protest in recent weeks.

The immediate trigger was an “extradition agreement” that China had demanded the city’s usually complaisant Legislative Council to pass. The agreement would put every Hong Konger who got on the wrong side of the Beijing authorities at risk of being hustled across the border where they would be at the mercy of China’s notoriously corrupt criminal justice system.

But the real causes of the unrest go much deeper.

China has been stealthily encroaching on the freedoms enjoyed by Hong Kongers since seizing control of the former British crown colony in 1997. Beijing began pre-selecting candidates for “Chief Executive” in 2014, a move that led to the Umbrella Revolution of that year.

More recently, Chinese public-security agents have been arresting — even kidnapping — Hong Kongers who criticize Beijing. Publishers have disappeared on trips to China in retaliation for releasing books critical of the Communist leadership. And in January, a Chinese-Canadian billionaire was abducted from Hong Kong by Chinese agents.

The people of Hong Kong were understandably alarmed by Beijing’s heavy-handed actions.

In fact, it was public anger at these abductions that led directly to China’s push for a formal extradition agreement — a clumsy attempt by the Beijing authorities to paper over their lawless actions with the fig leaf of a formal agreement.

The original Hong Kong agreement, negotiated between Margaret Thatcher and Deng Xiaoping, was supposed to guarantee citizens freedoms for 50 years — a full half-century — after China’s 1997 takeover.

China’s Communist dictators, however, are no great respecters of agreements. They were never comfortable with the “one country, two systems” formula that — on paper at least — puts Hong Kong’s separate political and economic “system” beyond their direct control.

For the moment, despite the ongoing protests, China is still content to operate through puppets like their handpicked chief executive, Carrie Lam, who decided to table the extradition agreement, hoping that this would quell the unrest.

It hasn’t. And now Beijing is taking no chances. Right across the border in Shenzhen it has set up an emergency command post, prepared to intervene if the Hong Kong police cannot control the situation.

Obviously sending in troops and tanks would be a last resort. But the regime is determined to maintain “stability” — in other words, crush any organized opposition to continued party rule the way it obliterated the Tiananmen demonstrations 30 years ago.

Beijing’s biggest fear is that the demonstrations will spread across the border. That’s why China’s battalions of censors are working overtime, trying to keep news about the demonstrations in Hong Kong from reaching the 1.4 billion Chinese in China itself.

Anything connected with the protests goes immediately into the dustbin of history. Videos showing the marchers singing “Do You Hear the People Sing?” from Les Mis, and “Sing Hallelujah to the Lord” have been taken down, and any audio versions of these two songs — the unofficial protest anthems of the marchers — have been scrubbed from behind China’s Great Firewall, as well.

Meanwhile, Beijing has been critical of comments by Secretary of State Mike Pompeo and House Speaker Nancy Pelosi, accusing them of interfering in China’s internal affairs. And Xi Jinping’s handlers insisted upon assurances that President Trump would not bring up the issue of Hong Kong during his meeting with the Chinese president at the G-20 summit last week.

But Beijing has reserved its real rancor for the British, who had the gall to suggest China should actually abide by its treaty obligations towards Hong Kong.

When British Foreign Secretary Jeremy Hunt suggested that China should respect the rights and freedoms set down in the Sino-British Joint Declaration, Foreign Ministry spokesman Geng Shuang accused Hunt of “grossly interfering in Hong Kong affairs” and laboring under a “colonial illusion.”

As far as the Sino-British agreement itself was concerned, China’s Foreign Ministry declared it “no longer has any practical significance.”

That’s what happens when you ask China to keep its word.

So far, there have not been copycat demonstrations in Chinese cities like Guangzhou or Shanghai. But that does not mean there is no sympathy for those in Hong Kong.

As one Chinese citizen wrote on the Web: “I feel such sympathy for those brave young people in Hong Kong. They’ve suffered for me, a coward who doesn’t dare to step out for fighting for those rights. I owe them.”

Steven W. Mosher is the president of the Population Research Institute and the author of “Bully of Asia: Why China’s ‘Dream’ is the New Threat to World Order.”