After winning House and Senate approval, the bill could complicate the administration’s already rocky talks with China to end the trade war.

A bill compelling the United States to support pro-democracy activists in Hong Kong could arrive on President Trump’s desk as soon as Thursday morning, potentially complicating the administration’s talks with China to end the trade war.

The bill, passed by the Senate on Tuesday, would require the government to impose sanctions on Chinese officials responsible for human rights abuses in the territory. On Wednesday, the House passed the Senate version 417-1, sending it to the White House.

If signed into law by Mr. Trump, the bill will also require the State Department to annually review the special autonomous status it grants Hong Kong in trade considerations. That status is separate from the relationship with mainland China, and a revocation of the status would mean less favorable trade conditions between the United States and Hong Kong.

The Senate passed the bill, the Hong Kong Human Rights and Democracy Act, by unanimous consent. The House had previously passed its own version unanimously, but gave assent to the Senate version in order to expedite the legislation. On the House floor on Wednesday, Speaker Nancy Pelosi said, “If America does not speak out for human rights in China because of commercial interests, we lose all moral authority to speak out on human rights elsewhere.”

Because the bill, in theory, has the support of a veto-proof majority in Congress, it could be enacted even if Mr. Trump vetoes it. And its enactment would most likely strain relations with China at a delicate moment in the trade negotiations.

Eswar Prasad, the former head of the International Monetary Fund’s China division, said the injection of Hong Kong into the trade process could derail the talks with China, which is notoriously sensitive about outside political interference.

“The legislation will further fuel the narrative in Chinese domestic policy circles that the U.S. is attempting to infringe on the sovereignty of China in terms of its internal economic and political affairs,” Mr. Prasad said.

Although Mr. Trump announced last month that the United States and China had reached a “historic” so-called phase one trade agreement, signing a deal has proved elusive. The two sides continue to negotiate and could achieve a deal in the next few weeks. But Mr. Trump has given mixed signals about whether he wants a deal.

“I haven’t wanted to do it yet because I don’t think they’ve stepped up,” Mr. Trump said on Wednesday afternoon while touring an Apple manufacturing facility in Texas.

The United States and China have been grappling over the fate of tariffs that Mr. Trump imposed on $360 billion of Chinese imports and additional tariffs that are due to be imposed on Dec. 15. China wants all of the tariffs rolled back as part of an agreement in which it would buy as much as $50 billion of American agricultural products a year and begin to open its markets to American companies.

Mr. Trump, however, is reluctant to scale back all the tariffs, and his advisers remain skeptical that China will live up to its commitments.

Henrietta Treyz, director of economic policy at the investment firm Veda Partners, said that the Hong Kong legislation raised the odds that the December tariffs will be imposed. She pointed to a series of caustic posts on Twitter written by the editor of The Global Times, a Chinese state-controlled publication, warning American farmers that the deal Mr. Trump promised them was not yet complete.

“Tensions are rising between the two nations, not dissipating,” Ms. Treyz said. “The prospect of not reaching a deal and requiring escalation from here remains quite real.”

The possibility that the Hong Kong bill could be signed into law has shaken the confidence of Wall Street analysts who had become increasingly optimistic in recent weeks that tariffs could be rolled back as part of the first phase of a trade deal.

Economists at Goldman Sachs said in a note to clients this week that the Hong Kong legislation was a potential “complication,” warning that China’s Ministry of Foreign Affairs had promised “strong countermeasures” if such a bill were enacted.

Still, the trade talks have continued over the last year despite several spikes in tension between the United States and China, including the arrest of the Huawei executive Meng Wangzhou in Canada and the sale of 66 F-16s to Taiwan this summer.

Mr. Trump, who rarely talks about human rights, has not spoken about the bill, nor has he made consistently strong statements in support of the Hong Kong activists. In June, he told China’s president, Xi Jinping, that he would not publicly back the protesters as long as trade talks were progressing.

While Mr. Trump’s advisers debate how much tariff relief to offer in the first phase of a trade deal, similar debates are playing out in China. The fact that the United States is weighing in so forcefully on Hong Kong is most likely exacerbating that internal tension.

“There’s an ongoing debate in Beijing between reformers who would like phase one and hard-liners who see themselves surrounded by hostile forces led by the United States, including in Hong Kong,” said Michael Pillsbury, a China scholar at the Hudson Institute who advises the Trump administration.

Ed Wong and Catie Edmondson contributed reporting.