Two recent victories for democracy in Hong Kong will likely prove to be mixed blessings for the citizens of the city. The landslide win by pro-democracy forces in local elections and U.S. President Donald Trump’s decision to sign legislation supporting those groups affirm the belief that democracy can take root in Chinese soil and that it should be nurtured. Unfortunately, the Chinese government sees both developments as a threat and is increasingly likely to roll back democratic gains in the Special Administrative Region.

Hong Kong voters turned out in unprecedented numbers for local elections last weekend. The electoral process was a both a counterpoint to and a continuation of the months of protests that have rocked the city. Nearly 3 million of the city’s 4.1 eligible voters cast ballots, the highest-ever turnout. Pro-democracy forces won 57 percent of the popular vote and 385 of the 452 seats contested, more than tripling the number of seats won in the last balloting in 2015. Pro-Beijing candidates claimed 41 percent of the popular vote and took 59 seats, a plunge from the 298 they have held since the last election. Independents took the remaining votes and hold the other seats.

Pro-democratic forces now control 17 of the 18 District Councils; previously, they controlled none. That matters not only because of the influence democrats now wield over local affairs, but also in the selection of the city’s chief executive. Nearly 10 percent of the seats (117) in the 1,200-member election committee, which chooses the Hong Kong chief executive, are reserved for district councilors. They are now likely to all be democrats.

Rather than seeing this as a desire to express in politically acceptable ways the preferences driving months of protests in Hong Kong, Beijing, which ultimately calls the shots in the city, sees this as proof of how misguided the people there are and as evidence of the subversive efforts of foreign “black hands” that China believes are behind the demonstrations. That belief animates Beijing’s call for a more rigorous and “politically correct” education of Hong Kong’s youth and the indignant denunciations of “foreign interference” in China’s internal affairs.

Outrage has been heightened by Trump’s decision to sign the Hong Kong Human Rights and Democracy Act. The bill authorizes sanctions on Chinese and Hong Kong officials who are involved in human rights abuses and requires the State Department to annually review the special trade status the U.S. grants Hong Kong. A second piece of legislation bans the sale of crowd-control munitions to the Hong Kong police.

Trump said that he feared the bill would undercut the prospects for a trade deal with China, an agreement that he claimed was nearly ready to be signed. That deal is all-important for him: He reportedly told Chinese leader Xi Jinping in a phone call last summer that he would not speak publicly in support of Hong Kong protests as long as trade talks were moving forward. He has also claimed that he warned Xi that a resort to force would scuttle the talks and that the threat had stayed Beijing’s hand. In reality, Trump had to sign. The bill passed the House of Representatives by a vote of 417 to 1 and enjoyed unanimous support in the Senate. If he had not signed the legislation, Congress would have overruled his veto.

Beijing was outraged, calling it a “serious intervention” in China’s internal affairs, “a grave violation of international law and basic norms governing international relations” and “an outright act of hegemony.” Hong Kong’s government was more measured, declaring its “strong opposition” to the bills and that it “deeply regretted that the U.S. has disregarded genuine concerns raised repeatedly by Hong Kong on the two acts.”

Attention will now turn to Carrie Lam, the chief executive of Hong Kong, who is the focus of much of the dissatisfaction of Hong Kong residents. They have been angered by the way that she (like all chief executives) is elected, and by her response to the demonstrations. That want a democratic selection process as well as an independent investigation of police behavior during the protests. The first will not happen and Lam has said existing review procedures are adequate. She has conceded, however, that the election results “reflect people’s dissatisfaction with the current situation and the deep-seated problems in society.” China continues to support Lam, but Beijing could decide to make her the scapegoat for all that has transpired and remove her from office. There is no sign, however, of any readiness by Beijing to acknowledge the roots of local anger. That means that a crackdown is increasingly likely. There is little chance that foreign governments can do anything to avert that disastrous decision, but they must try.

Japan must speak up loudly on behalf of democracy in Hong Kong and make clear that there cannot be business as usual — and certainly no visit to Japan by Xi next year — if there is a resort to force.