The Liberals beat the Conservative Party in a hard-fought by-election in the riding of Lac-Saint-Jean, scoring an upset victory that owes much to Prime Minister Justin Trudeau's personal popularity in Quebec.

The final results proved disappointing for the Conservatives, who lost the riding that they had held for a decade, as well as for the NDP that finished a distant fourth under the leadership of Jagmeet Singh. The Bloc Québécois finished in third place.

This was the first by-election in this Parliament in which the incumbent party failed to keep its seat. Liberal officials now hope that the victory of Richard Hébert, a local mayor, foreshadows their ability to win seats in the next election in ridings that have traditionally been hostile to their party.

Story continues below advertisement

Read also: Trudeau's government is defeating itself. The Liberals need to refocus if they want to win in 2019

Mr. Hébert won the riding with 38 per cent of the votes, giving him a 14-point lead over Bloc candidate Marc Maltais and Tory hopeful Rémy Leclerc.

Meanwhile, the Conservatives easily won another by-election in the riding of Sturgeon River-Parkland, with candidate Dane Lloyd taking more than 75 per cent of the vote after three-quarters of polls had closed. He will officially take over from former interim party leader Rona Ambrose as the riding's MP.

While the result in the Alberta riding was predictable, the by-election in Lac-Saint-Jean was seen as a four-way race from the start.

In the 2015 general election, the Conservatives won the riding with a five-point lead over the second-place NDP, while the Liberals and the Bloc Québécois finished in a near tie, 15 points behind the Conservatives.

Located northeast of Quebec City, the largely francophone and nationalist riding of Lac-Saint-Jean has traditionally been "bleu" – either of the Conservative or the Bloc Québécois hue.

The Liberals won only once in recent decades, in 1980, for a single mandate. Since 1984, the riding, which has seen its boundaries grow over time, has voted twice for Brian Mulroney's Progressive Conservatives, five times for the Bloc Québécois and four times for Stephen Harper's Conservatives.

Story continues below advertisement

The Conservatives have been holding on to the riding ever since former Roberval mayor Denis Lebel's victory in a 2007 by-election. Mr. Lebel became a cabinet minister in the Harper government and the party's Quebec lieutenant, winning a total of four elections. However, he announced in June that he was leaving politics and joining the Quebec Forest Industry Council.

The Liberals quickly started to prepare for the formal election period, hoping to capitalize on Mr. Trudeau's personal popularity in Quebec to score an upset victory.

Mr. Trudeau spent two days in late July in the riding, attending a large street festival in Roberval. The Liberals then held their Quebec summer caucus meeting in nearby Alma.

Then, shortly before the by-election call in September, the federal government announced more than $10-million in funding for improved high-speed Internet service and cellular coverage in the region.

Mr. Trudeau returned to the riding last week to address concerns over his government's handling of sensitive issues such as supply management in the agricultural sector and the softwood lumber dispute with the United States.

Out of power since 2015, the Conservatives waged an uphill battle to hold on to the riding under new leader Andrew Scheer, who has a relatively low public profile in Quebec. While Mr. Scheer twice visited the riding, the Conservatives also sent a large number of Quebec MPs and senators to campaign, including the party's Quebec lieutenant, Alain Rayes.

Story continues below advertisement

In an interview, Mr. Rayes said the Conservatives had to focus on contentious issues – such as the legalization of marijuana and the government's large deficits – to counter the Prime Minister's personal popularity in Quebec.

"We have a feeling that the honeymoon is over, but there is no doubt that the Prime Minister has a positive image with lots of people. It's our job to go after him on issues that affect people," he said before the polls closed.

The NDP finished in second place in the riding in the 2011 and 2015 general elections. However, the party was in the middle of a leadership race during a part of the campaign, which hindered the party's efforts. Still, NDP Leader Jagmeet Singh travelled to the riding to campaign, showcasing his French-speaking skills while facing a number of questions on his turban.