Mr. Trudeau’s Liberal Party will not retain its majority in Canada’s House of Commons, according to projections by the Canadian Broadcasting Corporation, but it will keep enough seats to allow Mr. Trudeau to form a government, with support from two left-leaning parties.

The victory was a personal vindication for Mr. Trudeau, who battled accusations that he had bullied his former attorney general, an Indigenous woman, and faced damaging revelations late in the race that he had dressed in blackface and brownface as a young man.

But these problems also clearly took a toll. The Liberals’ share of the popular vote fell throughout the country as it was losing its hold over the House of Commons.

“It’s a reflection of the fact that the shine has come off the Trudeau brand,” said Andrew McDougall, a professor of political science at the University of Toronto.