WEST PALM BEACH, Fla. — President Trump on Wednesday signed tough legislation that authorizes sanctions on Chinese and Hong Kong officials responsible for human rights abuses in Hong Kong, signaling support for pro-democracy activists and escalating tensions with Beijing as Mr. Trump tries to negotiate a trade deal with Chinese leaders.

China’s Foreign Ministry was furious, saying the bill “seriously interfered with Hong Kong affairs, seriously interfered with China’s internal affairs, and seriously violated international law and basic norms of international relations.” The ministry warned the United States against acting arbitrarily and said that any consequences would “be borne by the United States.”

Whether Mr. Trump would sign the legislation had been a subject of debate. He refused to commit to doing so as late as last Friday, saying that he supported the protesters but that President Xi Jinping of China was “a friend of mine.” But Mr. Trump was left with few options: The bill had passed both the House and the Senate by veto-proof majorities.

Mr. Trump’s decision, publicly announced the evening before Thanksgiving and after markets had closed, throws a potential wrench into the United States’ bilateral trade talks with China. Both countries have tried to keep the Hong Kong issue separate from their negotiations, which have been moving slowly.