WASHINGTON — President Trump refused to commit Friday to signing legislation overwhelmingly passed by Congress to support pro-democracy activists in Hong Kong, saying that he supported the protesters but that President Xi Jinping of China was “a friend of mine.”

The bill comes as Mr. Trump is trying to strike a trade deal with China, one of the central goals of his presidency. It puts him in the delicate position of trying to win China’s support for the pact while balancing growing calls from Congress to support the protesters who are taking on Beijing.

“I stand with Hong Kong,” he said during a nearly hourlong interview on the morning program “Fox & Friends.” “I stand with freedom. I stand with all of the things we want to do. But we’re also in the process of making the largest trade deal in history.”

Mr. Trump spoke warmly about Mr. Xi, calling him “an incredible guy” and “a friend of mine.” And he credited his trade negotiation with China as the reason Mr. Xi had not already extinguished the protests with a sweeping and violent crackdown that would have killed “thousands” of people.