Canada’s progressive prime minister Justin Trudeau has managed to hold on to power, albeit of a minority government, in one of the most divisive elections in the country’s history.

The 40-day campaign was a daily stream of insults, slurs, lies and explosive revelations about Trudeau and his Conservative rival Andrew Scheer.

Canada’s 43rd election was the nastiest in memory, aided and abetted by social media.

The vote saw east versus west, French versus English, urban versus rural, old versus new.

Still, by the time polls closed on Monday evening, the Liberal Party leader may have lost his majority but remained prime minister of a deeply divided country.

And that’s in spite of his Liberals dropping 30 seats and losing about 12 per cent of the popular vote they achieved in 2015.

Justin Trudeau Show all 8 1 /8 Justin Trudeau Justin Trudeau Day out The family get in the boat with climate change AP Justin Trudeau Keeping fit Jogging over the Alexandria bridge with the Mexican president AP Justin Trudeau Family comes first “Sophie inspires me every day to be better. I wouldn’t be here tonight if it weren’t for her leadership and her example." AP Justin Trudeau Three-way handshake Trudeau has vowed to strengthen international relations. Twitter Justin Trudeau Bromance Friendship with the White House The White House Justin Trudeau Pandas Just because. Twitter Justin Trudeau Yoga The plank became an internet sensation Twitter Justin Trudeau Making history Trudeau's gender-balanced cabinet was the first of its kind AP

As one analyst noted, the Liberals simply lost less than their Conservative Party of Canada rivals whose vote and seat count remained flat.

Instead, the beneficiaries were Trudeau’s rivals on the left.

Trudeau entered the election with a rock-solid majority but a series of gaffes at home and abroad deeply diminished his lustre.

“I think he’s been damaged goods for a while ... the India trip, SNC-Lavalin, blackface. It’s not just his image at home. Justin Trudeau staying as prime minister is a diminished figure, not just internally but externally in terms of the image of Canada in the world,” McGill University political science professor Daniel Beland told CBC.

And his preachiness didn’t help matters.

The political scion became known for a cynical sanctimony, lecturing Canadians for being racist, sexist and homophobic as well as a slew of other real and imagined sins.

His constant hectoring left many Canadians bewildered and angry.

When photos emerged of the progressive heartthrob in blackface, his woke reputation was left in tatters, soaked in a marinade of hypocrisy.

Trudeau makes his victory speech in Montreal on Monday (EPA)

Many came to see the prime minister as a disingenuous virtue-signaller more interested in scoring points at international forums than running the country.

“Canada is a divided country and this election has amplified that and speaks to the failure of Justin Trudeau to represent all Canadians,” the right-leaning Toronto Sun’s editor-in-chief, Adrienne Batra, said.

“His scandal plagued government has embarrassed our country on the international stage, he’s proven to be a fake feminist, all the while increasing taxes on hard-working Canadians.”

But Trudeau had the winning card in the form of an uninspiring Conservative Party of Canada rival, Andrew Scheer.

Scheer’s campaign was lead-footed from the start and frequently on the defensive over issues like abortion and climate change.

It’s not just his image at home. Justin Trudeau staying as prime minister is a diminished figure, not just internally but externally in terms of the image of Canada in the world Daniel Beland, McGill University professor of political science

The Conservatives, on the other hand, played to their base and moaned that Trudeau was ruining the country without offering any intelligent alternative.

National Post columnist Andrew Coyne summed up the mood of many Canadians two days before the election.

“Certainly neither of the two historic governing parties has begun to make the case for why they should be entrusted with power, as their sliding poll numbers reveal: if current trends hold, both will come in with less than a third of the vote, for the first time in our history,” Coyne wrote.

“That is as much a tribute to their leaders as it is to their platforms: if the worst that can be said of Justin Trudeau is that he could not defeat a morally and intellectually vacuous marshmallow like Andrew Scheer, the worst that can be said of Scheer is that he could not defeat a preening fraud like Trudeau.”

As Scheer and Trudeau snipped at each other like schoolboys, voters began to cast their eyes elsewhere.

The first stop was the socialist New Democratic Party and its charismatic leader, Jagmeet Singh.

In his pleas for a better deal for average Canadians, the youthful Singh won plaudits from across the political spectrum.

At times during the bitter contest, he appeared to be the only adult in the room.

Now, the ball is in his court.

Trudeau will need to rely on Singh’s NDP to preserve his precarious minority government status, and it is likely to cost him in reforms and money for social programmes.

Returning from the dead was the separatist Bloc Quebecois, which controls 35 Quebec seats in the reconstituted parliament.

But the party’s revival reflects a broad dissatisfaction with the political status quo rather than any renewed taste for separatism, the support for which is at an all-time low.

Also making inroads was the Green Party as fears over the climate crisis grew, but while its vote numbers rose, its seat total nudged up only slightly.

Trudeau has turned out to be a more conflicted politician than left-leaning Canadians had hoped he would be.

But when his operatives portrayed his rival Scheer as Trump 2.0 poised to destroy all that was good about Canada, it was enough to get him re-elected.

One pundit suggests that the minority government Trudeau will now preside over will be long-lasting.