President Trump delivered a sharp nationalist message and assailed “globalists” in remarks to the world’s leading international body on Tuesday, while stopping short of urging any specific action against Iran for a major attack on Saudi oil facilities that his administration has said was Tehran’s responsibility.

“If you want freedom, take pride in your country. If you want democracy, hold on to your sovereignty. And if you want peace, love your nation,” Mr. Trump said, as he called for stronger borders and new controls on migration. He added: “The future does not belong to globalists. The future belongs to patriots. The future belongs to sovereign and independent nations.”

The United Nations was founded in 1945 to foster international cooperation and to “take effective collective measures” to keep the peace after the nationalist fervor that had plunged the globe into World War II. But Mr. Trump, who spoke in an unusually flat monotone as he read from a teleprompter, stressed the value of national identity and argued that governments must defend their “history, culture and heritage.”

“The free world must embrace its national foundations,” Mr. Trump said. “It must not attempt to erase them or replace them.”