Justin Trudeau has won a second term as Canada’s prime minister after the country’s federal election, but his narrow victory means he will lead a minority government that will be forced to depend on other parties to govern.

Justin Trudeau's victory is a death knell for Canada's fledgling far-right Read more

With results still trickling in on Tuesday morning, the Liberals had 156 seats, 14 short of the 170 needed for a majority in the 338-seat House of Commons.

“We seek hardship for none and prosperity for all, and if we unite around these common goals, I know we can achieve them,” Trudeau told cheering supporters in Montreal. He said Canadians had sent a clear message of support for progressive policies.

Justin Trudeau (@JustinTrudeau) Thank you, Canada, for putting your trust in our team and for having faith in us to move this country in the right direction. Regardless of how you cast your vote, our team will work hard for all Canadians.

Despite Trudeau’s attempt to strike a conciliatory tone, Conservative leader Andrew Scheer issued a stark warning to the Liberals. “Mr Trudeau, when your government falls, Conservatives will be ready, and we will win,” Scheer told supporters at his concession speech.

Donald Trump was quick to congratulate Trudeau for “a wonderful and hard-fought victory”. Although the two leaders have not had a warm relationship – Trump described Trudeau as “dishonest” at last year’s disastrous G7 meeting in Quebec – the US president tweeted: “Canada is well served. I look forward to working with you toward the betterment of both of our countries!”

Four years after the Liberal leader swept to power promising “sunny ways” after nearly a decade of Conservative rule, Trudeau struggled to inspire voters as he campaigned for re-election.

Trudeau, 47, was endorsed by Barack Obama in the last days of the campaign, but his standing as one of the few remaining progressive leaders in a major democracy was undermined by the emergence of blackface images, and lingering criticism of his handling of a major corruption inquiry.

Before the vote, polls showed him neck-and-neck with Scheer. But with neither of the main parties reaching the number of seats needed for a parliamentary majority, Canada is headed towards a minority government, and Trudeau will be forced to co-operate with smaller left-of-centre parties to govern.

Play Video 1:28 Conservatives have put Trudeau on notice, says Andrew Scheer – video

“We’re seeing a much-needed chastening of the Liberal party,” said David Moscrop, a political scientist at the university of British Columbia. “Some of [the result] is a backlash against Liberal arrogance and entitlements. The Liberals set the bar so high they’re bound to run into it.”

In the final week of campaigning, Trudeau faced a strong challenge from the left-wing New Democratic party, led by Jagmeet Singh, which looked poised to peel away progressive votes from the Liberals.

But despite a surge in the polls in the final weeks of the campaign, the NDP was unable to convert that success into electoral wins. The party’s 44 seats were nearly cut in half.

The overall result laid bare the deep divisions in the country: not a single Liberal was elected in the two westernmost Prairie provinces, Saskatchewan and Alberta, which the Conservatives swept.

Trudeau lost key cabinet members, including veteran lawmaker and public safety minister Ralph Goodale, 70, who was the only Liberal MP in Saskatchewan, where the local energy industry is increasingly at odds with federal environmental policies.

In Alberta, Amarjeet Sohi, the natural resource minister, and Randy Boissonnault lost their seats, a result that means the neither Alberta nor Saskatchewan will have representation in Trudeau’s federal government, at a time of growing frustration in the economically strapped western provinces.

Jody Wilson-Raybould, the former attorney general and justice minister who was expelled from the Liberal party after publicly criticising Trudeau for his role in the SNC Lavalin scandal, was successful in her bid to retain her seat as an independent.

The first Indigenous person to hold one of the most powerful positions in government, Wilson-Raybould played a central role in one of the most damaging episodes in Trudeau’s first term of office, when she testified the prime minister and his staff improperly pressured her to abandon the criminal prosecution of engineering giant SNC Lavalin.

After she resisted, she was shuffled out of the position of attorney general and eventually ejected from the party.

Facebook Twitter Pinterest Conservative leader Andrew Scheer supporters watch the election results come in at his campaign headquarters Photograph: Todd Korol/Reuters

Jane Philpott, the former treasury board president and close friend of Wilson-Raybould, was also booted from the party for criticising Trudeau. But her attempt as an independent candidate to keep her seat in Ontario failed, with a disappointing third-place finish for the one-time Liberal star.

Monday’s result marked a clear defeat for Scheer, whose campaign pledges to quash carbon pricing legislation and cut taxes failed to resonate with voters. The Conservative party also took a heavy loss, with deputy party leader Lisa Raitt losing her race to former Olympic kayaker Adam van Koeverden.

Meanwhile, Maxime Bernier, the leader of the populist People’s Party of Canada, which critics have called xenophobic and racist, lost his seat. It means the former Conservative minister’s newly formed party will have no presence in the House of Commons.

After his landslide victory in 2015, Trudeau positioned himself as a progressive force in Canada and aboard: he welcomed Syrian refugees when the US and other countries were closing their doors, and he legalized cannabis nationwide.

But in a country heavily reliant on natural resources, his efforts to strike a balance on the environment and economy have been criticized by the right and the left. His government brought in a carbon tax to fight the climate crisis – but also paid billions to rescue a stalled pipeline project.

Monday’s result marks a significant erosion of support for the charismatic prime minister, but the narrow victory will be enough to ensure Trudeau’s marquee policies – including the national carbon tax – are likely to remain in place.

But without his majority, Trudeau will have to reach out to other parties with a “confidence-and-supply” deal in which junior partners will support the government on individual pieces of legislation, as opposed to joining in a fully-fledged coalition.

Such a deal will leave the leftwing NDP and the Bloc Québécois holding the balance of power a minority government. The most likely ally for Trudeau is Singh, who has made a commitment to fighting climate change and funding healthcare key requires for co-operation from the NDP.

• The sub heading of this article was amended on 23 October 2019 to more accurately describe the outcome of the election and on 24 October 2019 because an earlier version incorrectly said “not a single Liberal was elected in the western Prairie provinces”. That should have said they won no seats in the two westernmost Prairie provinces, Saskatchewan and Alberta.