President TrumpDonald John TrumpTrump at rally vows to supporters no name change for 'Thanksgiving' Trump says he will designate Mexican drug cartels as terror organizations State Dept. official describes frantic effort to save recalled Ukraine ambassador MORE on Wednesday signed legislation offering support for pro-democracy protesters in Hong Kong, one week after it passed the House and Senate with veto-proof majorities.

The White House made the announcement that Trump had signed the Hong Kong Human Rights and Democracy Act despite protests from officials in Beijing, who complain that the legislation meddles in their domestic matters.

"I signed these bills out of respect for President Xi, China, and the people of Hong Kong," Trump said in a statement. "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."

The legislation imposes sanctions on individuals who commit human rights violations in Hong Kong and blocks them from entering the United States.

It would also require the State Department to provide an annual report to lawmakers on whether Hong Kong remains "sufficiently autonomous" from China.

Beijing had called the bill "unnecessary and unwarranted," and officials there threatened retaliatory measures if it became law.

Wednesday's announcement capped days of uncertainty over whether Trump would sign the legislation into law. While administration officials and experts said it was unlikely he would veto the measure given that move would be overturned by Congress, the president had in recent days refused to commit to signing it.

Trump has described the Hong Kong protests as linked to the trade deal his administration has been negotiating with Beijing and voiced a desire to balance those two interests.

"I stand with Hong Kong. I stand with freedom. I stand with all of the things that we want to do," Trump told "Fox & Friends" last week.

"But we also are in the process of making the largest trade deal in history," he continued. "And if we could do that, that would be great. China wants it. We want it. And I will say this. If it weren't for me, thousands of people would have been killed in Hong Kong right now."

The U.S. and China are still working to finalize a "phase one" trade agreement that was first announced more than a month ago. The president has repeatedly claimed that ongoing trade talks have kept violence in Hong Kong at bay.

Pro-democracy protesters in Hong Kong have clashed with law enforcement for months. The protests were sparked by a bill that would have allowed some citizens to be extradited to China and have persisted in the weeks since the legislation was withdrawn.

The demonstrations have been marred by violent clashes with law enforcement. Tensions spiked again this month when officials reportedly threatened the use of lethal ammunition on demonstrators if they did not vacate Hong Kong Polytechnic University’s campus.

Lawmakers in both parties warned Trump against putting the trade deal ahead of support for the protesters.

"Today marks a great victory for the people of #HongKong and the fight for autonomy and human rights!" Sen. Rick Scott (R-Fla.) tweeted.

Sen. Marco RubioMarco Antonio RubioHouse Democrat asks USDA to halt payouts to Brazilian meatpacker under federal probe Supreme Court weighs lawsuit pitting climate scientist against skeptics Senate passes legislation supporting Hong Kong protesters MORE (R-Fla.) said in a statement that the decision "could not be more timely in showing strong U.S. support for Hong Kongers’ long-cherished freedoms."

Pro-democracy candidates in Hong Kong won sweeping victories earlier this week in local elections amid a groundswell of voter turnout.