Canadian Prime Minister Justin Trudeau's Liberal Party held onto power in a nail-biter of a general election, but as a weakened minority government.
Television projections declared the Liberals winners or leading in 157 of the nation's 338 electoral districts.
His main rival Andrew Scheer and the Conservatives picked up 121, after polling stations across six time zones closed.
As early as today, Mr Trudeau will have to form an alliance or formal coalition with one or more smaller parties in order to govern.
The first test of his future government will follow in the subsequent weeks with a speech to parliament outlining his legislative priorities and a confidence vote.
The 47-year-old former school teacher dominated Canadian politics over the four years of his first term, but faced a grilling during the 40-day election campaign, which was described as one of the nastiest in Canadian history.
His golden boy image has been damaged by ethics lapses in the handling of the bribery prosecution of engineering giant SNC-Lavalin, while the emergence of old photographs of him in blackface makeup rocked his campaign.
Mr Scheer, meanwhile, only two years after winning the leadership of his party, struggled to win over Canadians with his bland minivan-driving dad persona and a throwback to the thrifty policies of past Tory administrations.
His Conservatives had stood alone among all of the parties in pledging austerity measures to return to a balanced budget within five years.
Surging social democrats and resuscitated Quebec separatists also appeared to have chipped away at Liberal support.
Thank you, Canada, for putting your trust in our team and for having faith in us to move this country in the right direction. Regardless of how you cast your vote, our team will work hard for all Canadians.— Justin Trudeau (@JustinTrudeau) October 22, 2019
The Bloc Quebecois came back from a ruinous 2015 election result, tapping into lingering Quebec nationalism to take 32 seats, while the New Democratic Party (NDP) won 25 seats, according to projections.
Some 27.4 million Canadians were eligible to vote in the election, and a large turnout was expected but that will not be confirmed until later this morning.
During the campaign, Mr Trudeau evoked the bogeymen of past and current Tory parties fostering "politics of fear and division" while Mr Scheer called the prime minister a "compulsive liar," "a phony and a fraud".
Mr Trudeau had warned against Mr Scheer's pledged rollback of environmental protections, including a federal carbon tax that discourages the use of large amounts of fossil fuels.
The pair exchanged barbs while attack ads and misinformation multiplied. At one rally, the prime minister wore a bulletproof vest due to security fears.
Mr Scheer had lamented that Canadians "cannot afford" a Liberal government propped up by the third-place New Democratic Party (NDP).
NDP leader Jagmeet Singh, a leftist former criminal defence lawyer, is the first non-white leader of a federal political party in Canada, and will likely emerge as kingmaker.
Late in the campaign, Mr Scheer was shaken over revelations of his US dual citizenship and allegations that his party hired a communications firm to "destroy" the upstart People's Party, led by former Conservative foreign minister Maxime Bernier.
The Green Party, hopeful for a breakout, managed to add only one seat, bringing its tally to three.
Congratulations to @JustinTrudeau on a wonderful and hard fought victory. Canada is well served. I look forward to working with you toward the betterment of both of our countries!— Donald J. Trump (@realDonaldTrump) October 22, 2019