TORONTO — Prime Minister Justin Trudeau stood in Parliament on Wednesday and apologized for Canada’s decision to turn away a steamliner full of Jewish refugees fleeing Nazi Germany on the eve of the Holocaust 79 years ago, saying it reflected years of regrettable anti-Semitic foreign policy.

The Canadian government at the time, run by the same Liberal party that Mr. Trudeau leads today, refused to allow the steamliner, the St. Louis, to land in June 1939 after it had been blocked from docking at its original destination, Havana. The boat was filled with more than 900 passengers, most of them Jews who had fled Germany four months before World War II began.

“We apologize to the mothers and fathers whose children we did not save, to the daughters and sons whose parents we did not help,” Mr. Trudeau said.

The United States also refused the captain’s desperate pleas for asylum, as did Argentina, Uruguay, Paraguay and Panama. In the end, the boat returned to Europe, but not to Germany. Jewish organizations secured them visas to Britain, the Netherlands, Belgium and France. But, as Germany expanded its territory, some 254 were captured and killed in Nazi death camps.

“We refused to help them when we could have. We contributed to sealing the cruel fates of far too many at places like Auschwitz, Treblinka and Belzec. We failed them. And for that, we are sorry,” said Mr. Trudeau, wearing a red poppy on the lapel of his suit as is Canadian tradition in November to mark Remembrance Day.

Since he was elected three years ago, Mr. Trudeau has made apologizing a regular ritual, even by Canadian standards. The apologies, in large part, are a reflection of the country’s continued struggle to atone for its colonial and racist past, particularly when it comes to its treatment of First Nations people.

While some have begun to roll their eyes, other Canadians say they are proud the country is making amends.

[Want more Canadian coverage in your inbox? Subscribe to our weekly Canada Letter newsletter.]

Canadians today tend to think of their country as compassionate and tolerant. But its position on Jewish refugees before, during and after the war was infamously articulated by one government official at the time: None is too many.

Britain accepted 70,000 Jewish refugees between the rise of Hitler in Germany in 1933 and the end of the war in 1945. The United States took in 200,000. Vast and underpopulated Canada accepted 5,000.

Mr. Trudeau’s apology came less than two weeks after a gunman opened fire in a Pittsburgh synagogue, killing 11 worshipers, and at a time when anti-Semitism is rising across North America. It was not lost on many that it was delivered the day after an American election campaign marked by refugee-bashing.

“The rhetoric we are hearing across the border is very similar to the rhetoric we heard in the 1930s — the vilification of the other, the vilification of the press. It’s really scary,” said Danny Gruner, who attended Wednesday’s apology with his mother, Ana Maria Gordon, the sole survivor of the St. Louis living in Canada today.

Ms. Gordon, who met with Mr. Trudeau privately, was surrounded by many of her great-grandchildren and grandchildren.

Last week, Mr. Trudeau apologized to a British Columbia First Nation for the government’s treachery in inviting six Tsilhqot’in chiefs to peace talks 150 years ago. Instead of talking, the government arrested them, put them on trial and hanged them.

He has also apologized to Omar Khadr, the only Canadian who was held at the United States military base at Guantánamo Bay, Cuba. He emotionally apologized to gay members of the army, the police and in public service who were persecuted — some even imprisoned — because of their sexual orientation.

And he tearfully said sorry to indigenous people in the province of Newfoundland and Labrador, where for much of the 20th century indigenous children were torn from their families and compelled to attend boarding schools, where many were abused.

“You will not remove the guilt from the perpetrators of the horror,” Mr. Gruner said. “But at least you can come to terms with what the country was at the time, and try to understand where we are at this particular time and where we want to be.”

Judith Steel, an 80-year-old grandmother from Queens, traveled to Ottawa to witness Mr. Trudeau’s apology. She was 14 months old when she boarded the St. Louis with her parents.

They ended up in France, where she was hidden for the duration of the war. Both her parents were sent to Auschwitz in occupied Poland, and murdered.

“I felt the prime minister’s heart. He was just so open and honest,” said Ms. Steel, who cried throughout Wednesday’s ceremony.

“Apologies are a very big part of my life,” said Ms. Steel, who immigrated to the United States after the war to be raised by her aunt and uncle. “What eats you up is the anger, the fear and all the emotions that go with loss. We have to forgive — not for them, but for ourselves.”

On Wednesday, Mr. Trudeau mentioned the growing anti-Semitism that has bubbled up in Canada, as it has in the United States, and vowed to stamp it out.

“Canada and all Canadians must stand up against xenophobic and anti-Semitic attitudes that still exist in our community, in our schools and in our places of work,” he said.

Canada’s policy toward Jews during and after World War II was exposed by two university professors, first in an academic paper and later in the 1982 book, “None Is Too Many: Canada and the Jews of Europe. Their findings had a profound effect on the country’s psyche and directly influenced the Canadian government’s decision to open its arms to Vietnamese refugees, accepting some 60,000 people fleeing the Communist government.

That legacy continued as the country accepted around 58,000 refugees fleeing the Syrian war over the past three years.

But after Mr. Trudeau tweeted that refugees were welcome in Canada, “regardless of your faith,” and asylum seekers began to flood across the border from the United States into Canada, the topic of immigration has become politically heated in the country again.