The Liberals and Conservatives each won two of the four federal byelections Monday night, a result that maintains the electoral status quo but may be seen as a partial victory for Justin Trudeau's party — which nearly pulled off an upset in a Manitoba Conservative stronghold. 

The Manitoba riding of Brandon-Souris had been too close to call all night. At one point, Liberal candidate Rolf Dinsdale had taken a slight lead, but Tory candidate Larry Maguire, a prominent provincial MLA, was able to claim victory, winning by just under 400 votes. Maguire secured 44.1 per cent of the votes compared to the Liberal candidate's 42.7 per cent.

"Thank you Brandon-Souris! Your support tonight is truly appreciated," Maguire tweeted shortly after his victory.

The Liberals did hold on to Toronto Centre, where Chrystia Freeland defeated NDP candidate Linda McQuaig. They also retained Montreal's Bourassa riding, where Liberal candidate Emmanuel Dubourg claimed victory.

"The NDP is no longer the hopeful optimistic party of Jack Layton," Liberal Leader Justin Trudeau said in Montreal. "It is the Liberal Party tonight that proved that hope is stronger than fear."

'The NDP is no longer the hopeful optimistic party of Jack Layton.'- Liberal Leader Justin Trudeau

The race in Toronto Centre had shaped up into a contest between two journalists; Freeland, a former Reuters executive and author, and McQuaig, an author and former Toronto Star columnist​. Freeland won over McQuiag by a substantial margin — 49.1 per cent to 36.4 per cent.

In the Liberal stronghold of Bourassa, Dubourg, who won 48.1 per cent of the vote, will be replacing former Liberal MP Denis Coderre, who stepped down to run for municipal office and is the city's newly elected mayor. 

Stéphane Moraille, a former singer in the musical group Bran Van 3000, the candidate for the NDP, came in second with 31.4 per cent.

Dubourg's first post-election tweet reaffirmed his agreement with his party's stance on marijuana legalization.

"I am for regulation and therefore the legalization of marijuana," he wrote.

Conservative candidate Ted Falk claimed victory in the riding of Provencher in Manitoba.

Falk recorded a big victory, winning 58.1 per cent of the vote compared to Liberal candidate Terry Hayward who trailed with 29.9 per cent support.

The longtime Tory stronghold was most recently represented by former cabinet minister Vic Toews, who retired from politics in July after almost 13 years as the area's MP.

Brandon-Souris a top priority

Of the four contests, the byelection in Brandon-Souris had become a priority for the party leaders as the normally Conservative stronghold was seen to be vulnerable, in part because the nomination process for Maguire rankled some Tories.

Ted Falk victory speech

Conservative Ted Falk delivers his victory speech at the legion in Steinbach, Man., on Monday night. (Chris Glover/CBC)

Trudeau had personally visited the riding three times, NDP Leader Tom Mulcair had visited twice and several federal Conservative cabinet ministers have made the trek to the riding.

Prime Minister Stephen Harper, who has for weeks fended off opposition attacks about the Senate spending scandal, took the unprecedented step of sending a personal letter to Brandon constituents — an indicator of what's at stake in this riding.

Since Trudeau was chosen as the federal Liberal leader last spring, the party has risen from third place in the polls, back into first place, with the Conservatives slightly behind. The NDP has sunk back to its traditional third-place slot.

With files from The Canadian Press