In 2015, he suggested that mosques were incubating radicals. He constantly claimed that the West was fighting not just the Islamic State, but was at war also with “the international jihadist movement.” He intervened to slow the admission of refugees from Syria, saying some were potential terrorists, and prioritized Christian asylum seekers from Syria and Iraq. Sound familiar?

In the early 2000s, well before American states approved legislative or administrative measures banning the Shariah law that was not coming and could not possibly come to America, Ontario had its own Shariah hysteria. When a small group of Muslims sought permission to use religious arbitration in business disputes and such family matters as divorce and marital assets — to duplicate what churches and rabbinical courts had long been doing — there was a public furor. The province’s premier, Dalton McGuinty, a Liberal, was finally forced to ban the practice for all faith groups.

In Quebec, Islamophobia manifested itself in a series of sensational cases, in 2007 and 2008, over the “reasonable accommodation” of religious minorities, Muslims in particular. The provincial soccer federation barred hijab-wearing girls on the pretext of safety. It took an official commission to calm public nerves. Its 2008 report, which had the eminent philosopher Charles Taylor as an author, found there was no crisis: Sensationalist media coverage had distorted perceptions, but Muslims were not making unreasonable demands.

Even so, in 2010, Quebec’s premier, Jean Charest, went ahead with a ban on the niqab for government employees and for anyone receiving a public service, including health care. The Muslim-bashing continued in 2012 with the election of the separatist Parti Québécois, which the following year proposed a ban on all religious attire and symbols, such as the kipa, hijab and the Sikh turban, from the public sector. The chief target was Muslims, as the government made abundantly clear in proposing to fire hijab-wearing women from government employment, including in day-care centers, schools and hospitals.

But, this being Canada, we took comfort in the fact that the Parti Québécois government was rejected at the polls in 2014, precisely because of its reactionary identity politics, and that the Harperites were trounced in the federal election of November 2015. Canadians had finally decided that Mr. Harper had crossed a red line with his Muslim-baiting. In that election, Muslim voter turnout was a record 79 percent, compared with the overall turnout of 68 percent.

In his victory speech, Prime Minister Trudeau spoke of meeting a worried hijabi woman during the campaign and he assured the nation that “a Canadian is a Canadian is a Canadian.” Mr. Trudeau reversed Mr. Harper’s policy on Syrian refugees and welcomed more than 35,000 refugees during his first year in government. Today, hardly a week goes by without my hearing about a neighbor or friend, or a church, synagogue or community group, going to the airport to welcome their Syrian family.

I remain an incurably optimistic Canadian, and I want to believe that Canada is still not the United States. But as Sunday’s attack showed, we face the challenge of undoing the damage of years of suspicion and bigotry.