Media playback is unsupported on your device Media caption "Canadians voted in favour of a progressive agenda" - Justin Trudeau's victory speech

Prime Minister Justin Trudeau has retained power in Canada's election but lost both his majority and - by a slight margin - the popular vote. Here is a breakdown of the good news for his Liberal party - and the bad.

Good news - he's still in power

It was a tough election battle for the Liberals but there was the sense late on Monday night among party faithful in Montreal that they could now breathe a little easier.

When TV networks began projecting a Liberal minority, supporters at the election night headquarters erupted into chants of "four more years" as a sense of relief passed through the crowd.

"The Liberals did better than we thought they would," said supporter Brian, who chose not to give his last name, saying he had been spooked by polls that suggested a tighter race.

Former Liberal MP Marlene Jennings says voters "have shown they still have trust in the Liberal government and in Justin Trudeau, and they definitely didn't want a Conservative government, not even a minority government".

Still, Ms Jennings conceded she had grown frustrated watching the campaign get sidetracked by "so-called scandals" during the last few weeks.

"There were times during the campaign where I wanted to take the Liberal strategists and shake them and say: 'Why aren't we talking about the great things we've done over and over again?'"

Bad news - his star power is diminished

Mr Trudeau had an exceptionally long honeymoon by most political standards - but his popularity has clearly dimmed with the Canadian public.

Where did he stumble?

Media playback is unsupported on your device Media caption Four years of Justin Trudeau in two minutes

Even before the election campaign began on 11 September, his approval ratings had slipped.

The first trouble with the Canadian public came after a disastrous overseas trip to India, which took place against a backdrop of photo-ops showcasing the Trudeau family in elaborate traditional Indian outfits.

Then came the SNC-Lavalin affair - an ethics scandal related to attempts to pressure a former attorney general to cut a deal for a firm facing a corruption trial, which further tarnished Mr Trudeau's personal brand.

That former attorney general, Jody Wilson-Raybould, was booted out of the Liberal party by Mr Trudeau.

Against the odds, Ms Wilson-Raybould ran and won as an independent in her Vancouver riding.

Image copyright Reuters Image caption Jody Wilson-Raybould

She is a vocal critic of Mr Trudeau and will serve as a reminder of that scandal in the House of Commons.

Finally, revelations that Mr Trudeau wore blackface - widely seen as a racist caricature - on at least three occasions shook the Liberal campaign and forced Mr Trudeau to ask Canadians to forgive him for his past misbehaviour.

Bad news - the Liberals lost the West

The prairie provinces of Alberta and Saskatchewan turned entirely Conservative blue - with the exception of one New Democratic Party (NDP) stronghold in the city of Edmonton.

That blue wave helped the Conservatives gain almost 30 seats in Monday's election, taking them from 95 to about 122.

The Liberals were never going to sweep those deeply Conservative regions. Even at the height of their popularity in 2015 they only held a handful of seats in those two provinces.

But now Alberta and Saskatchewan have turned solidly away from Mr Trudeau's party amid a sense in western Canada that its interests are not represented in Canada's capital of Ottawa.

With final results still rolling in early Tuesday morning, the Conservatives also had a slight lead in the popular vote - 34.5% to the Liberals' 33%.

That did not escape the attention of Conservative leader Andrew Scheer who said in his speech to party faithful that "more Canadians wanted us to win than any other party".

Bad news - the Bloc bounced back

The Bloc Quebecois has also had a resurgence.

Voters had relegated the party calling for sovereignty for Quebec to the sidelines in the last two elections - but its fortunes turned under the new leadership of Yves-Francois Blanchet, and they more than tripled its seat count, from 10 to an estimated 32.

Image copyright Getty Images

Mr Blanchet campaigned under the slogan "Quebec, c'est nous" or "We are Quebec", and on being a strong voice in Ottawa for that province's interests.

The party, which only runs candidates in Quebec, is at odds with Mr Trudeau on issues like the province's controversial secularism law - Bill 21 - which prevents judges, police officers, teachers and public servants holding some other positions from wearing religious symbols such as the kippah, turban or hijab while at work.

Mr Trudeau did offer an olive branch to those Canadians who rejected the Liberals at the ballot box, and said he had heard the frustration from prairie voters loud and clear.

"To those who did not vote for us, know that we will work every single day for you," he said. "We will govern for everyone."

Good news - he can still govern with a minority

Mr Trudeau will need the support of other parties to enact his promised "progressive agenda" if he wants to hold on to power.

One likely ally is the NDP, who could help the Liberals to survive key confidence votes and to pass legislation.

But that support comes at a cost.

Image copyright Getty Images Image caption From left: Justin Trudeau, Andrew Scheer and Jagmeet Singh

NDP leader Jagmeet Singh has already set out his party's laundry list of priorities in a minority situation: support for a national pharmacare plan, investments in housing, addressing student debt, lowering cell phone and internet bills, action on climate, and raising taxes on the wealthiest Canadians.

But Mr Singh's position is less clear on the Trans Mountain pipeline project, which would triple the capacity of crude oil the current pipeline carries to the west coast.

Mr Trudeau's Liberals support the project, saying it is in Canada's national interest.

In his speech to supporters late in the early hours of Tuesday, Mr Singh vowed his party would play a "positive role" in Ottawa.

But support for a minority government also usually has an expiration date.

On average, minority governments in Canada last about a year and a half to two years, much shorter than the usual four-year majority term.

Good news - voters do want climate action

The Conservatives had pledged to immediately repeal Mr Trudeau's signature climate policy if they came to power.

But now it looks like the federal carbon tax - imposed on four provinces that did not already have their own cap-and-trade programme or price on carbon in place - will live another day.

It should not be too difficult for Mr Trudeau to secure support from across party lines for his climate policies.

Media playback is unsupported on your device Media caption What's more important to Canadians — the economy or the environment?

The NDP, the Bloc Quebecois and Canada's Greens, which added a seat in Atlantic Canada, all campaigned on taking action on the environment.

"You've asked us to show even more vision and ambition as we tackle the greatest challenge of this era - climate change," Mr Trudeau said in his victory speech.

"That is exactly what we'll do."