Faced with a Liberal shutout in Alberta and Saskatchewan and rising tensions in the West, Prime Minister Justin Trudeau ended the election campaign by vowing to govern for all Canadians when his MPs return to Ottawa.

Trudeau spoke directly to Western Canadians in his victory speech in Montreal early Tuesday morning, telling them they are "an essential part of our country."

"I've heard your frustration and I want to be there to support you. Let us all work hard to bring our country together," he said.

Trudeau, who brought the Liberal Party from third place to a landslide majority win in 2015, finished this campaign with a more modest victory: a minority government.

With a reduced seat count, Trudeau will now need to work with other parties on a case-by-case basis to pass budgets and legislation, or work to build a more formal arrangement with another party or parties.

During the campaign, Trudeau repeatedly warned that the Conservatives, if elected, would make deep cuts that would harm Canadians. He said Liberals now have a "clear mandate" to go in a different direction.

"Tonight from coast to coast to coast, Canadians rejected division and negativity. They rejected cuts and austerity and they voted in favour of a progressive agenda and action on climate change," he said.

After failing to win a single seat in Saskatchewan or Alberta, Liberal Leader Justin Trudeau says he has heard those provinces' frustrations. 2:01

One of Trudeau's most trusted ministers, veteran Saskatchewan politician Ralph Goodale, was defeated, along with Alberta minister Amarjeet Sohi, but other members of the Liberal cabinet were re-elected.

Facing a western backlash over his government's carbon tax and failure to build a new pipeline, Trudeau vowed that his team will work for everyone, no matter how they voted.

"We will govern for everyone," he said. "Regardless of how you cast your ballot, ours is a team that will fight for all Canadians."

The 40-day campaign was marked by daily barrage of insults between leaders — and a succession of embarrassing revelations about candidates unearthed by party operatives.

McGill University political science professor Daniel Beland said Trudeau's weakened mandate capped off a campaign that was less than inspiring.

"They have not really galvanized Canadians this time around. It's quite a different campaign than 2015 — more nasty in tone, with the message being about who not to vote for than who to vote for," he said.

Beland said that if the Liberals can hold a relatively stable minority, they will likely rally behind Trudeau's leadership — at least for now.

"They will want to stay in power at any cost, but there will be talk behind the scenes about who is next," he said.

Blackface scandal

The biggest blow to Trudeau's campaign came early on, when photos emerged of him dressed in blackface in his 20s.

Beland said that revelation served to further tarnish a reputation that was already scarred.

"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," he said.

Liberal commentator Susan Smith concedes there were a "few bumps" in the campaign, but said Trudeau reacted to the blackface controversy with an apology and a genuine expression of humility.

She said she believes his international reputation remains firmly intact.

"'Barack Obama' is all I have to say with regards to that," she said, referring to a tweet from the former U.S. President endorsing Trudeau in the final days of the campaign.

As for Trudeau's future as leader, Smith argued the Liberal Party will need his negotiating skills more than ever in a minority government situation, citing as an example his government's ability to complete the NAFTA talks.

Smith said he sees relations with the provinces emerging as a key challenge of Trudeau's second term in office.

Warnings about Conservative cuts

Throughout the campaign, the Liberal leader spoke about how Conservative premiers cut services and limited access to abortion services — a strategy designed to raise fears that a Conservative federal government under Andrew Scheer would do the same.

In some cases, it was the Conservative premiers who initially picked the fights with the Liberals. Ontario's Doug Ford drew unflattering comparisons between Trudeau's fiscal management and the record of former premier Kathleen Wynne, while Alberta Premier Jason Kenney skewered Trudeau over the carbon tax and the Liberal government's failure to build a new pipeline.

But after the dust settles, Smith said Trudeau will try to work with the provinces to "look for ways to move the country forward."

"The premiers have got to do what is best for their people in their provinces, and that includes sitting down at the table and having a conversation about pharmacare, affordable housing and other things. So they won't be able to dig in 100 per cent from a partisan perspective," she said.

University of Calgary political science professor Melanee Thomas said a less skilled politician would have been "toast" after the blackface scandal.

Much of Trudeau's positive "rhetoric," though, hasn't been backed up by substantial action on issues such as equality and reconciliation, she said.

"It seems like his brand and his narrative around himself — his sunny ways, equity and diversity and ... a better way of doing politics ... the actions that need to go along with that to make it really credible have been wanting," she said.