Trump acted after markets closed ahead of the Thanksgiving holiday and under pressure from lawmakers in both parties. The legislation authorizes sanctions on Chinese and Hong Kong officials involved in human rights abuses and requires the State Department to perform an annual review of the special trade status that Washington grants Hong Kong.
"I signed these bills out of respect for President Xi, China, and the people of Hong Kong," Trump said in a statement issued from his Florida resort home. "They are being enacted in the hope that Leaders and Representatives of China and Hong Kong will be able to amicably settle their differences leading to long term peace and prosperity for all."
China opposes the bill, but it enjoys overwhelming support in Congress.
The House passed the Hong Kong Human Rights and Democracy Act by a vote of 417 to 1 on Nov. 20. The lone holdout was Rep. Thomas Massie, R-Ky. That vote came one day after the Senate approved the measure unanimously.
Trump's decision to sign the bill puts an end to what could have been a politically uncomfortable veto showdown with members of his own party. While Trump has expressed ambivalence about how aggressively the United States should support the protesters while his administration is negotiating a trade agreement with Beijing, Republican lawmakers have been far more outspoken.
"Know this, Chairman Xi: Americans despise tyrants and stand in solidarity with Hong Kong. The whole world has seen both the courage of Hong Kongers and the brutality of your Chinese Communist Party," Sen. Ben Sasse. R-Neb., said in a statement issued after Trump signed the law. "As long as freedom-seekers fill the streets of Hong Kong, the American people will take their side."
Senate Foreign Relations Committee Chairman Jim Risch, R-Idaho, and ranking Democrat Robert Menendez of New Jersey both issued statements welcoming the president's signature.
"Without question, the American people support the people of Hong Kong, and this law makes that abundantly clear to Hong Kongers, the international community, and the Chinese Communist Party," Risch said. "The Hong Kong Human Rights and Democracy Act is an important step forward in holding the Chinese Communist Party accountable for its erosion of Hong Kong's autonomy and its repression of fundamental human rights. This law is the product of a true bipartisan, bicameral effort, and I am gratified that we came together with one voice to tell the people of Hong Kong that the United States stands with them."
In Beijing, the foreign ministry denounced Trump's decision, calling it a "serious intervention" China's internal affairs.
"It is a grave violation of international law and basic norms governing international relations. It is an outright act of hegemony, which the Chinese government and people firmly oppose," a ministry spokesman said in a statement.
The Chinese authorities have repeatedly accused Western powers led by the United States of fomenting unrest in Hong Kong as a way to try to destabilize China.
Thursday's statement warned that "no foreign government or power has the right to intervene."
"This so-called bill will only make the Chinese people, including Hong Kong compatriots, further understand the sinister intentions and hegemonic nature of the United States. It will only make the Chinese people more united," it said in characteristically trenchant language. "The U.S. plot is doomed to fail."
Trump was asked Tuesday what message he had for Hong Kongers who voted for democracy parties in local elections over the weekend.
"Well, we're with them," Trump replied. He did not address the Hong Kong legislation.
"I have a very good relationship, as you know, with President Xi. We're in the final throes of a very important deal - I guess you could say, one of the most important deals in trade ever. It's going very well," Trump said. "But at the same time, we want to see it go well in Hong Kong, and I think it will. I think that President Xi can make that happen. And I know him, and I know he'd like to make it happen."
Pro-democracy candidates won overwhelming victories in Hong Kong's district council elections, which also saw a record turnout.
The legislation led to a diplomatic incident Monday when China's Foreign Ministry summoned U.S. Ambassador Terry Branstad to lodge a protest over American "meddling" in China's internal affairs. China warned that it would retaliate if Trump signed the bill.
Branstad in turn told Chinese officials that Washington remains concerned about Hong Kong and opposes intimidation tactics by the authorities.
Trump says he has asked Xi not to use the military to quell the protests.
In recent comments, Trump has suggested that he is being cautious in his approach to Hong Kong because of the sensitivity of trade talks. He has also alleged - without providing evidence - that he has personally saved the lives of thousands of people by warning Xi that more deaths in Hong Kong would scuttle the trade negotiations.
Trump had hoped to secure a major trade deal with China earlier this year, but the talks have faltered multiple times. He is now trying to secure a partial trade deal with China, an agreement he has referred to as "Phase One" and which would include large purchases of U.S. farm products by Beijing. But even nailing down that agreement has proved difficult.
Sign up for the daily JWR update. It's free. Just click here.