OTTAWA — As President Trump’s executive order on immigration stranded people around the world and provoked condemnation, Prime Minister Justin Trudeau of Canada took to social media to restate the country’s open-door policy.

“To those fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith,” Mr. Trudeau wrote on Twitter on Saturday afternoon. “Diversity is our strength.”

Another post showed him in photograph with a child, apparently a Syrian refugee who had just arrived, with the caption “#WelcomeToCanada.” The post was shared at least 224,000 times on Twitter.

Mr. Trudeau’s immediate priority after he took office in late 2015 was to drastically accelerate the entry of refugees from Syria. From that point to early January, the latest available figures, his administration has admitted 39,671 refugees into a country with a population of about 36 million.