DANANG, Vietnam — President Trump on Friday vowed to protect American interests against foreign exploitation, preaching a starkly unilateralist approach to a group of leaders who once pinned their economic hopes on a regional trade pact led by the United States.

“We are not going to let the United States be taken advantage of anymore,” Mr. Trump told business leaders at the Asia-Pacific Economic Cooperation forum in Danang, Vietnam. “I am always going to put America first, the same way that I expect all of you in this room to put your countries first.”

But taking the stage at the same meeting immediately after Mr. Trump, President Xi Jinping of China delivered a sharply contrasting message, championing more robust engagement with the world. Mr. Xi used his own speech to make a spirited defense of globalization, saying relations among countries should be “more open, more inclusive, more balanced, more equitable and more beneficial to all.”

Mr. Trump’s remarks were strikingly hostile for an audience that included leaders who had supported the Trans-Pacific Partnership, a sweeping 12-nation accord that was to be led by the United States, from which Mr. Trump withdrew immediately after taking office.