N AHEED NENSHI , Calgary’s ebullient mayor, says that when he was elected in 2010—becoming the first Muslim to lead a large North American city—only the foreign media brought up his religion. The local press never mentioned it. That changed when he ran for re-election for a third term in 2017. People “suddenly started talking about race and religion”, sometimes abusively, online. Although his rivals avoided bigotry, it encouraged formerly non-voting racists to turn up at the polls. He still won. Four years ago, when Justin Trudeau was elected, “Canada was bucking the trend,” says Mr Nenshi. Now it is learning that “we’re not immune at all” to the political maladies of the age.

The point of Mr Trudeau’s premiership has largely been to boost Canada’s immunity with a liberal tonic that combines social justice and environmentalism with advocacy of globalisation and a dash of redistribution. The test of whether he has succeeded will not be whether he wins the election in October. Rather, it will come if he loses. Would a Conservative government sustain the broader themes of Canadian liberalism even as it discarded Mr Trudeau’s particular brand of it?

Geography, history, political culture, the electoral system, the structure of the economy and the welfare state all argue for optimism. They keep the political climate temperate. American slugfests over judicial appointments are foreign to Canada. The head of the panel to advise Mr Trudeau on picking the next Supreme Court justice is a former Progressive Conservative prime minister.

Canada’s comfort with diversity goes back to British colonists’ “incomplete conquests” of indigenous groups and French-speaking settlers, Peter Russell, a historian, has argued. Surrounded by three oceans and the United States, Canada can largely decide what diversity will look like. It was a Progressive Conservative prime minister, John Diefenbaker, who in 1962 ended Canada’s policy of favouring white immigrants. This year Canada intends to accept 330,000 newcomers, nearly 1% of its population. The number is set to rise. Around 90% of immigrants eventually become citizens.

They are a diverse bunch. In 2017 the top four countries of origin of new permanent residents were India, the Philippines, China and Syria, who made up 47% of the total between them. Asked in 2016 what makes their country unique, 43% of Canadians, without prompting, said multiculturalism and diversity, according to a poll conducted by the Environics Institute. That was far ahead of land and geography, at number two. Constituencies that swing elections, such as the eastern and southern suburbs of Vancouver and the 905 area code around Toronto, have large numbers of voters from immigrant backgrounds. No aspiring prime minister dares provoke them.

Yet Mr Nenshi’s experience is a warning. Polling finds little increase in hostility towards “visible minorities”: 40% say too many are coming, compared with 38% in 2013, according to EKOS, an Ottawa firm. What has changed is how those attitudes are divided by party. Among supporters of the Conservatives the share that is suspicious of non-white immigrants has jumped from 47% to 69%. Among Liberal backers it has dropped from 34% to 15%. On this and issues such as climate change, “polarisation in Canada is pretty damn close to what it is in the US ,” says Frank Graves of EKOS .

That may be overstating it. But recent events at Roxham Road suggest he has a point. A few miles west of an official border post between New York state and Quebec, Roxham Road is an entry point for “irregular” migrants to Canada. Before President Trump, just a few crept across. Since 2017 some 45,000, mostly non-American, migrants have sought asylum in Canada.

The irregular uptick sparked uproar and strained Canada’s pro-immigration consensus. This may be “the first time in history that immigration is an election issue nationally”, says Christian Bourque of Leger Marketing, a market-research firm in Montreal. In response, the government slipped in a measure to stop “asylum shopping”, preventing refugees from filing claims if they have already done so in a safe country such as America.

Andrew Scheer’s Conservatives—the party lost the “Progressive” qualifier in a merger with Stephen Harper’s Canadian Alliance in 2003—have a trickier problem. Their voters are more alarmed by Roxham Road than are the Liberals’. Conservatives face a challenge from Maxime Bernier, a former federal minister from Quebec who calls himself a “smart populist” and wants to reduce the annual immigration target to 250,000—roughly what it was under Mr Harper. His People’s Party is low in the polls, but the Conservatives cannot dismiss him. Nor can they veer from the centre by pandering to nativism.

Canadian liberalism is so deep-rooted that it does not depend on a Liberal victory

While defending immigration, Mr Scheer hinted that Canada could become a bit less welcoming. As prime minister he would “set immigration levels consistent with what is in Canada’s best interests”. If anyone detects a dogwhistle, a Conservative will set them straight. The Conservatives are “one of few right-of-centre parties that is strongly pro-immigration”, says Michelle Rempel, an MP from Alberta.

In effect, Conservatives are betting on the robustness of Canada’s liberal antibodies and their own. Mr Scheer’s election pitch, which includes undoing gun controls brought in by the Liberals, cutting tax and ending national carbon pricing, may seem to have a whiff of Trumpism. Yet Canadian populism “is not the kind of divisive demagogic variety we’ve seen in Europe”, says Jason Kenney, who was Mr Harper’s minister for immigration and for multiculturalism and citizenship before becoming Alberta’s premier. The day after uttering those words he spoke in what sounded like creditable Punjabi to thousands of Sikhs at a parade in Calgary—not something Mr Trump or Marine Le Pen could be imagined doing.

Both sides are bracing for a bitter election. The clash between Mr Trudeau’s new-age liberalism and Mr Scheer’s conservatism may test Canada’s defences against immoderation, but they should hold. Canadian liberalism is so deep-rooted that it does not depend on a Liberal Party victory. If Mr Trudeau loses, the world will no longer be looking to him, as Mr Biden prophesied back in 2016. But liberals will still look to Canada. ■