“The Conservative government tried to use wedge politics, but in the end, it backfired,” said Andrew Griffith, a former director general of the government office that oversees citizenship matters and the author of a book about multiculturalism in Canada. “It should give any political party in Canada food for thought, food for reflection.”

The move was uncharacteristic even for the Conservatives, who assiduously courted immigrant communities even before they first won power in 2006, particularly in two areas that often decide the balance of power in Parliament: the suburbs of Toronto and Vancouver, British Columbia. The Liberals and the New Democratic Party also seek support there, but the Conservatives often found that their more traditional approach to many social issues found an eager audience.

Canadian law makes it relatively easy to move from landed immigrant to citizen, and Mr. Griffith said that many newcomers became politically active once they could vote. Because Canada’s immigration rules favor well-educated and affluent migrants, ethic communities are also an important source of donations to political parties, not least because the country’s campaign finance laws ban contributions from corporations or unions and set a relatively low ceiling for individuals.

“It’s empowering in that there are groups that can no longer be ignored,” said Arif Virani, 43, a newly elected Liberal lawmaker from Toronto who came to Canada with his parents as an Ismaili Muslim refugee from Uganda in 1972. He noted that in some constituencies, all three major parties ran minority candidates.

At times over the past decade, Jason Kenney, a Conservative cabinet minister, seemed to be appearing at just about every ethnic celebration in the country — a butter-chicken circuit that appeared to take a toll on his waistline. But Mr. Kenney’s courtship of ethnic minorities, Mr. Griffith said, was undone when the Conservative government decided to make it harder for recent immigrants to bring in relatives, when it was slow to accept Syrian refugees and when it tried to ban the niqab, or face covering, during citizenship ceremonies. Mr. Harper’s use of the phrase “old-stock Canadians” on the campaign trail made matters worse.