The Liberals lost support in every province across Canada in yesterday's federal election, and it cost them their majority government.

But it wasn't enough to cost them power.

Justin Trudeau will remain prime minister because voters in Quebec and Ontario didn't want to give the job to Conservative Leader Andrew Scheer.

The Liberals took a beating from coast to coast. With 33 per cent of the vote, the party lost 6.5 percentage points from the last federal election in 2015. It put the Liberals behind the Conservatives, who jumped 2.5 points to a little more than 34 per cent.

For the first time since 1979, the party that won the most votes didn't win the most seats — and by a healthy margin.

With 157 seats, the Liberals have a big minority government. But nearly three-quarters of the Liberal caucus will hail from just two provinces, Ontario and Quebec, while two other provinces — Alberta and Saskatchewan — won't have a single member sitting on the governing benches.

That alone explains much of what happened last night.

Ontario electoral map doesn't look that different

The Liberal vote in Ontario and Quebec held up pretty well. In Quebec, the Liberals dropped to 34 per cent support, a little more than a percentage point from 2015. In the process, the Liberals lost six seats to the Bloc Québécois, which surged by about 13 percentage points in the province — though not enough to topple the Liberals as the most popular party in Quebec.

In Ontario, the Liberals were down only about three percentage points, still managing to take over 41 per cent of the vote in the province and outpacing the Conservatives by a significant margin. That only cost the Liberals a net loss of one seat.

The key for the Liberals was holding their vote in the decisive Greater Toronto Area. They swept all 25 of Toronto's seats and even increased their share of the vote slightly. They also came out of the surrounding suburbs with 24 of 29 seats — identical to where they were on election night in 2015.

Losses to the Conservatives in a handful of rural ridings were made up for with a few gains in southwestern Ontario. Electorally, the province doesn't look much different than it did four years ago.

And that is why the Conservatives came up short.

Conservative gains not where they needed them

With disappointing results in Atlantic Canada — the Conservatives captured just four seats — and underwhelming performances in Quebec, the significant gains the Conservatives made in Western Canada were not nearly enough. The GTA was always the most important place for Scheer to make gains if he was to win this election. It didn't happen. Instead, the Conservative share of the vote dropped by about five points in the region.

There was something about the Conservative message that didn't resonate with Ontarians. Everywhere else in the country outside of Quebec the Conservative vote went up. The gains were most significant in Manitoba, Saskatchewan and Alberta, where the party's share of the vote jumped by double-digits.

But there were only so many new seats to grab in that part of the country. The Conservatives took back the four seats in Alberta they lost to the Liberals in 2015 and swept all of Saskatchewan. Two Liberal seats in the suburbs around Winnipeg also fell to the Conservatives.

Liberal MP Chrystia Freeland handily won her Toronto riding of University-Rosedale Monday night, part of a Liberal sweep of the Greater Toronto Area. (Chris Helgren/Reuters)

Those are important gains for the Conservatives, including the defeat of Liberal cabinet ministers Amarjeet Sohi in Edmonton Mill Woods and Ralph Goodale in Regina–Wascana. It was this surge in support in Western Canada — which did not pay off much in terms of seat gains — that is behind the Conservatives' popular vote win.

Just look at Alberta. Only one of the 33 Conservatives elected in the province failed to get a majority of ballots cast in their riding. Most of them get more than 70 per cent of the vote.

But that just ran up the numbers where the Conservatives already held seats. It was the Liberals' ability to hold on to their seats in Central and Eastern Canada by narrower margins that made the difference. In all, the Liberals lost 15 seats west of Ontario, more than their combined losses east of the Lakehead.

NDP, Greens struggle to get their vote out

Another factor that contributed to the somewhat unexpected scale of the Liberal win was the performance of the New Democrats and the Greens.

The Greens, who have historically underperformed compared to polling expectations in virtually every election at both the federal and provincial levels, stayed true to that tradition. Their support was slipping in the final days of the campaign and dropped to just 6.5 per cent on election night — a disappointing result considering that the Greens managed to get 6.8 per cent of the vote in the 2008 federal election when they failed to win a single seat.

The party held its two seats on Vancouver Island but wasn't able to make the hoped-for gains in the region. A win in Fredericton looks more like an exception — the result of the increased popularity of the Green brand in Atlantic Canada following provincial breakthroughs in New Brunswick and Prince Edward Island, along with a collapse of the NDP vote in these two provinces.

Conservative Leader Andrew Scheer increased his party's support but was unable to win new seats in the Greater Toronto Area. (Michael Bell / Canadian Press)

But it was the performance of the New Democrats that was more of a surprise. While the Greens were trending down, the NDP was riding some momentum going into election day. In the end, the NDP performance didn't match its polling, taking about 16 per cent of the vote nationwide when most polls showed the party in the 18 to 19 per cent range.

This underachievement was most obvious in seats in which the NDP has historically had some strength and should have been more competitive. In Atlantic Canada, the NDP finished a distant third in Acadie-Bathurst and was about 12 points behind the Liberals in Halifax.

Some of the seats targeted by the NDP in central Toronto were won by the Liberals by big margins: 14 percentage points in Toronto–Danforth and 16 points in Parkdale–High Park. Conservative gains in the Toronto suburbs was one thing the Liberals had to be worried about. NDP progress in the downtown core was the other. Neither happened.

Climate of change in Quebec

Quebec maintained its reputation as the most volatile province in recent Canadian elections. Fully 25 of its 78 seats changed hands — nearly as much as the rest of the country combined.

While a few individual Liberal candidates knocked off some NDP incumbents, on the whole, there were a lot of losses in Quebec. The Liberals dropped six seats, the NDP lost all but one of its seats and the Conservatives fell from 12 Quebec MPs in 2015 to 10. People's Party Leader Maxime Bernier was defeated.

The Bloc returned with a vengeance, just finishing behind the Liberals in the popular vote and taking 32 seats, the party's best performance since the 2008 election and a result that suggests the Bloc was the top choice of francophones in the province.

NDP Leader Jagmeet Singh and his wife, Gurkiran Kaur, greet supporters during an election night party in Burnaby, B.C. The NDP fell short of the support some polls had predicted, ending the night with 16 per cent of the vote. (Darryl Dyck / Canadian Press)

With the exception of the traditional Liberal strongholds of Montreal, Laval and the Outaouais, the Bloc won every region of the province — even knocking off a few Conservative incumbents in the Quebec City region. It was largely at the expense of the New Democrats that the Bloc made its return, with only NDP MP Alexandre Boulerice in Rosemont–La Petite-Patrie surviving the cull.

What's the path to a majority now?

It raises a few questions about the future of every party in the House of Commons.

Where do the New Democrats go from here in Quebec, the province that took them to official opposition party status in 2011 and put them in the running to form a government in 2015?

What do the Greens have to do to make sure their support doesn't disappear on election day?

And is the Bloc back for good?

The questions for the Conservatives and Liberals are more existential. The future of both parties looks murky when the Liberals have been pushed out of much of Western Canada and francophone Quebec. The Conservatives activated their base once again, but they lack representation in some of Canada's biggest cities and took a significant step backwards in their outreach to Quebec.

Unless either party can figure out how to reconnect with these electorates, neither will be in the running to form a majority government in the near future. In the short term, it's all about making the next Parliament function. In the longer term, it is about bridging the divides that are polarizing the country — and potentially making minority governments all the more likely.