Justin Trudeau has held on to power in the Canadian election, but failed to win a majority, according to projections by Canada‘s national broadcaster, CBC.

Despite a tense start to the night with the Liberal Party suffering some losses, Mr Trudeau was projected to secure enough seats to form a minority government following a 40-day election period viewed by many as one of the most toxic campaigns in recent memory.

With Liberals winning or leading in 156 out of 338 seats in Monday’s vote, according to Elections Canada, Mr Trudeau has likely beaten Conservative rival Andrew Scheer to secure his second term as prime minister, in spite of repeated scandals that have plagued the 47-year-old throughout his campaign.

Despite polls showing Mr Trudeau’s Liberal Party in the lead, no party is expected to have reached the 170-seat mark needed to form a majority government.

Mr Scheer’s Conservative Party is projected to win 121 seats, making it the second most popular party in the country on Monday, when voters cast ballots at some 20,000 polling locations. The progressive New Democratic Party, led by Jagmeet Singh, was previously expected to be the third most popular party, but Bloc Québécois is now likely to take third place with 32 seats.

Elizabeth May’s Green Party is currently projected to win three seats, according to CBC, meanwhile Maxime Bernier, leader of People’s Party of Canada, has lost his seat.

These exit polls come after one of the most contentious elections in modern Canadian history, spurred in part by repeated scandals that have plagued Mr Trudeau and his administration.

While polls suggest healthcare was the top issue for Canadian voters, with climate change not far behind, the election season was focused on Mr Trudeau’s admission that he had used blackface on numerous occasions, and on accusations that he had improperly intervened in an ongoing criminal case against Quebec construction company SNC-Lavalin.

Those scandals saw a sharp decline in Mr Trudeau’s polling, and left his notable accomplishments on issues like climate change and other notable liberal focuses like welcoming refugees, expanding gender representation in the government, and Census question changes.

To underscore Mr Trudeau’s precarious position, former US president Barack Obama even broke from tradition to weigh in supporting the Canadian prime minister, risking accusations of foreign influence on the Canadian elections.

Andrew Scheer's supporters chant 'lock him up' about Justin Trudeau

“I was proud to work with Justin Trudeau as president,” Mr Obama wrote. “He’s a hard working, effective leader who takes on big issues like climate change. The world needs his progressive leadership now, and I hope our neighbours to the north support him for another term.”

The decline in fortunes is a stark change from the 2015 election, when he awakened so-called “Trudeaumania” that had also brought his late father, Pierre Trudeau, into power in the 1960s.