OTTAWA — First came the revelation that Prime Minister Justin Trudeau had not only worn blackface as a young man but couldn’t remember how many times he had done so.
Then came the televised candidate debates, often overshadowed by acidic personal insults and the contenders rudely talking over one another.
Just when it seemed it couldn’t get any more un-Canadian, four people were arrested at a campaign event for a populist leader in Hamilton, Ontario, where protesters chanted “Nazi scum” and tried to block an elderly woman with a walker from entering.
On Monday, many Canadians likely breathed a sigh of relief as they voted in national elections after a campaign that left many feeling disillusioned with politics, and with a sense that Canada, often a model for the world, had lost its way.
In a country that prides itself on its humanism and decorum, experts said the election campaign was one of the most acrimonious in recent years — as well as the tightest.
Mr. Trudeau and Andrew Scheer, leader of the Conservative Party and Mr. Trudeau’s main opponent, have been locked in a statistical tie in poll after poll throughout the campaign — although over the weekend, analysts saw a slight shift in the prime minister’s favor. And the fight became personal.
Lori Turnbull, a professor of political science at Dalhousie University in Halifax, Nova Scotia, said the lack of constructive political debate and focus on childish name-calling was nothing less than “tragic.”
“It shocks me that this has been one of the most policy-void elections that we’ve ever seen,” she said. “The narrative of the campaign has been leaders taking swipes at one another and trying to find ways to get people to not trust the other person.”
What a difference four years can make.
In 2015, Mr. Trudeau, a telegenic young leader, captured the hearts and minds of Canadians by promising “sunny ways” of doing politics, and a new approach to foreign policy focusing on women’s rights, multilateralism and the fight against climate change. “Canada is back,” he famously said.
But buffeted by controversies and the challenge of being an incumbent, Mr. Trudeau struggled even as his opponents seemed unable to capitalize on his weakness. In sharp contrast to four years ago, when Mr. Trudeau energized young and first-time voters to turn out, this time he faced the risk that they would stay home.
He also became an object of derision, attacked by Mr. Scheer during a debate as a “phony” and “fraud” who isn’t what he appears to be.
The nastiness of the campaign has been met with voter apathy, analysts said.
“What we’re seeing with the electorate is the rejection of the political class, of the political establishment and elites,” said Shachi Kurl, the executive director of the Angus Reid Institute, a nonprofit polling group in Vancouver, British Columbia.
“There’s a pox-on-your-houses element,” she said, adding that the campaign had been a missed opportunity for both Mr. Trudeau’s Liberal Party and Mr. Scheer’s Conservatives. Both, she said, had failed “to make the case to Canadian voters, as the front-running parties, they should become government.”
Such anger with politics-as-usual has girded recent electoral rebellions in Europe and the United States though in Canada it has so far not been accompanied by a substantive rise in populism. Maxime Bernier, a far-right populist leader who is running in the election, is expected to fare poorly.
Still, such a tight election was not expected even as late as the beginning of this year.
It appeared then that Mr. Trudeau would stroll toward a second term. His surprise election victory in 2015 brought a burst of energy to Canadian politics and propelled him to become an emblem of liberal progressivism on the world stage.
Upon election, he created a gender-balanced cabinet and stepped up efforts to make amends for Canada’s historical wrongs against Indigenous people.
His government introduced significant measures including a national carbon tax plan, and it legalized assisted dying and recreational marijuana.
Mr. Trudeau swiftly moved to admit 25,000 Syrian refugees, personally handing out parkas to some on their arrival. He stood up to President Trump, securing a sweeping trade agreement with the United States and Mexico while getting the president to back down on steel and aluminum tariffs.
The country prospered, with unemployment at its lowest level in decades.
Those achievements seemed to have overcome disappointments like a trip to India, where the prime minister’s fondness for dressing in local ceremonial clothing embarrassed many back home, as well as a deterioration of relations with China and a broken promise to change how Canadians vote.
But Mr. Trudeau’s carefully groomed image began to shatter after his former attorney general and justice minister, Jody Wilson-Raybould, accused him of improperly pressing her on how to handle a criminal corruption case against a major engineering company.
Mr. Trudeau wanted her to use a new law to settle the case with a hefty fine, rather than pursuing a criminal conviction. He said he was trying to save jobs because a criminal penalty would have barred the company, SNC-Lavalin, from government work.
But Ms. Wilson-Raybould, an Indigenous leader, said Mr. Trudeau and his male aides had bullied her. Parliament’s ethics commissioner later found that Mr. Trudeau had broken conflict-of-interest laws.
When the campaign officially began in September, Mr. Trudeau appeared to be bouncing back from the controversy when old photographs of him wearing brownface and blackface appeared, and longstanding questions about his character and authenticity resurfaced.
Mr. Trudeau may benefit from having an opponent who lacks his star power. Mr. Scheer has argued that he better understands and empathizes with middle-class citizens, who are also the prime minister’s target audience.
But that argument may not resonate beyond his base of traditional supporters. An opponent of abortion who appears to avoid gay pride parades, Mr. Scheer’s social conservatism has turned off many Canadians.
Professor Turnbull said Mr. Scheer had failed to make a case for becoming prime minister.
“You can’t tell why Scheer wants to be prime minister,” she said. “I look at him and I’m like: ‘Why do you want to be prime minister? What is it that motivates you?’”
A month ago, Professor Turnbull said, she hadn’t anticipated such a dispiriting campaign, particularly given the enthusiasm of four years ago.
“I’m trying to think of an election that has had that kind of effect but I can’t really,” she said. “We had six people at the leaders’ debate and they were not going after each other in a policy sense, they were going after each other in a personal sense. So why would we identify with that?”