President Trump suggested Friday that he might veto legislation designed to support pro-democracy protesters in Hong Kong — despite its near-unanimous support in the House and Senate — to pave the way for a trade deal with China.

Speaking on the “Fox & Friends” morning program, the president said that he was balancing competing priorities in the U.S.-China relationship.

“We have to stand with Hong Kong, but I’m also standing with President Xi [Jinping],” Trump said. “He’s a friend of mine. He’s an incredible guy. ... But I’d like to see them work it out. Okay? We have to see and work it out. But I stand with Hong Kong. I stand with freedom. I stand with all of the things that we want to do, but we also are in the process of making the largest trade deal in history. And if we could do that, that would be great."

The House on Wednesday passed the Hong Kong Human Rights and Democracy Act by a vote of 417 to 1. The lone holdout was Rep. Thomas Massie (R-Ky.). That came one day after the Senate had approved the measure on a unanimous vote.

The veto-proof majorities indicate that Congress could overrule the president if he tries to block the bill from becoming law. Trump has only vetoed five measures since becoming president, and Congress has not overridden any of his vetoes so far. Overriding a presidential veto requires a two-thirds vote in both the House and Senate.

As the U.S.-China trade talks approach the one-year mark, the episode shows how other elements of the relationship between the world’s two largest economies are influencing prospects for a deal.

The president’s uncertain remarks drew swift opposition from members of both parties. Sen. Ted Cruz (R-Tex.) said the Hong Kong bill "will become law. This was a true bipartisan moment and a clear signal to the rest of the world that political threats from corrupt regimes will not stand in the way of America supporting the millions of freedom fighters in Hong Kong.”

Senate Minority Leader Charles E. Schumer (D-N.Y.) accused the president of going soft on the Chinese leader. “For a guy who promised to be tough on China, President Trump’s reliable deference to President Xi is all the more bewildering,” Schumer said in a statement. "Being tough on China when it comes to human rights will also help us win the battle on trade.”

Once a bill is passed by both chambers of Congress, the president has 10 days to sign it into law or to veto it. If he does neither, it will become law automatically. That means Trump has until early December to decide.

The legislation authorizes sanctions on Chinese and Hong Kong officials involved in human rights abuses and requires the State Department to conduct an annual review of the special status that the U.S. grants Hong Kong in trade matters.

The bill threatens to complicate trade negotiations that already are stalled on several key issues. Chinese officials have criticized the congressional action as interference in their internal affairs. Vice President Pence said this week it would be “very hard” to finalize a trade deal if China resorts to violence to put down the protests, now in their sixth month.

But some experts say Xi will keep the trade talks and the Hong Kong protests on separate tracks. The Chinese economy grew at a 6 percent annual rate in the quarter that ended September 30, its slowest pace in 27 years. And the trans-Pacific tariff war is only adding to economic pressures, giving officials an incentive to negotiate a ceasefire. If Xi sees a trade deal as easing his economic woes, he will sign it regardless of other irritants in China’s relationship with the U.S., said Aaron Friedberg, a China scholar at Princeton University.

“The idea of linkage between Hong Kong and the trade talks is largely a figment of Trump’s imagination. I doubt that the Chinese side has made any such overt connection although, now that Trump has done so, they may be happy to reinforce the idea that, if we somehow go easy on them on Hong Kong, they may eventually ink that illusive ‘great deal,’” said Friedberg, a former adviser to Vice President Dick Cheney.

China regained sovereignty over Hong Kong in 1997, ending more than 150 years of British colonial rule. Maintaining control over the prosperous enclave, which Beijing governs under the “one-country, two-systems” framework, is a top priority for Xi. But there has been widespread tension in Hong Kong for months over China’s governance of the economic hub, triggering large - at times, violent - protests that have led to multiple deaths.

Chinese officials would likely react sharply if the U.S. legislation becomes law. But that reaction wouldn’t necessarily imperil the negotiations, according to Jeff Moon, a former U.S. trade negotiator in the Obama administration. In the past, China has reacted to perceived slights by denying permission for U.S. Navy vessels to make port visits to Hong Kong, he noted.

“Trump’s task is to de-link Hong Kong from trade, and to help Xi find a way to express displeasure over U.S. legislation without taking precipitous action that will create indefinite deadlock in the trade war," Moon said. “The irony here is that Trump’s comments on Fox signal uncertain resolve and negotiating weakness in the trade war while talks are faltering and he needs to show determination to press China on the whole range of issues, not just agricultural products and tariffs.”

Trump last month announced an “agreement in principle” with China on a partial trade deal, which he hoped to sign by mid-November. But talks have deadlocked over the details of Chinese purchases of U.S. farm products and plans for the removal of Trump’s tariffs on $360 billion in Chinese goods.

Trump’s comments Friday come one day after Sen. Marco Rubio (R-Fla.), one of the authors of the Hong Kong legislation, predicted on CNBC that the president would sign the measure.

“My understanding is that they will sign it,” Rubio said, referring to the White House.

Trump’s public comments about Hong Kong have been inconsistent. In June, he said a resolution of the protests was between Hong Kong and China “because Hong Kong is part of China.”

Two months later, he tweeted that Xi should “humanely” deal with the situation before a trade deal was inked. “Of course China wants to make a deal. Let them work humanely with Hong Kong first!” the president wrote.

The president has faced calls from lawmakers in both parties to speak out about what’s at stake in Hong Kong’s escalating demonstrations. “The world should hear from him directly that the United States stands with these brave men and women," Senate Majority Leader Mitch McConnell said this week.

On Friday, Sen. Ron Wyden, the senior Democrat on the Senate Finance Committee, said: “Basic human rights in Hong Kong aren’t something Donald Trump can bargain away. Congress has overwhelmingly spoken against the Chinese government’s violent repression of peaceful protest, and any action by Donald Trump to side with China over Congress must be quickly overridden.”

The president also told Fox, without evidence, that he had saved the lives of thousands of Hong Kong demonstrators by telling Xi not to intervene.

“The only reason he’s not going in is because I’m saying it’s going to affect our trade deal,” Trump said.

The U.S.-China trade talks have charted a winding path for the past year. Trump and Xi agreed to launch negotiations last December 1 over a steak dinner in Buenos Aires, on the sidelines of the Group of 20 leaders’ summit.

Negotiators failed to meet their initial March 1 deadline, but Trump agreed to delay a planned tariff increase while talks continued. At the beginning of April, Trump said negotiators were close to an “epic” deal that could be finalized “within the next four weeks.”

Instead, the talks fell apart in May, with U.S. officials accusing the Chinese of reneging on a nearly-complete deal and the president expanded tariffs to additional Chinese products later in the summer.

- Seung Min Kim contributed reporting