Canadian Prime Minister Justin Trudeau's Liberals held onto power after a closely fought election on Monday but were reduced to a minority government that will need the support in Parliament of a smaller left-leaning party.
The vote showed a deeply divided country with the defeated Conservatives winning the popular vote, while a resurgent separatist Bloc Quebecois made big strides in the mainly French-speaking province of Quebec.
The Liberals had won or were leading in 156 out of 338 seats in Monday's vote, according to Elections Canada. That put the Liberals far short of the 170 seats needed for a second straight majority government.
"You did it, my friends. Congratulations," Trudeau told supporters in Montreal early on Tuesday, speaking as his main opponents were giving concession speeches.
Trudeau, who took power in 2015 as a charismatic figure promising "sunny ways," saw his popularity drop over old photos of him in blackface and his handling of a corporate corruption case. He will now have to rely on the New Democratic Party (NDP) to push through key legislation.
Although the NDP had a disappointing night, with the 24 seats it had won or was leading in down sharply from the 2015 election when it won 44, the party could exercise significant influence over Trudeau's next government.
"I think a Liberal government supported by the NDP is likely going to lean farther left," said John Manley, a former Liberal finance minister who now works in the private sector.
"It raises a series of issues about what are the demands that an NDP party would make. What's the price of governing going to be? I think businesses are going to be reluctant to make any moves until they get some satisfaction around that."
NDP leader Jagmeet Singh said he had spoken with Trudeau and
told him his party would be "working hard to deliver on making sure we deliver the priorities that Canadians have."
Minority governments in Canada rarely last more than 2-1/2 years.
Ahead of the vote, opinion polls showed a tight race between Trudeau and his main rival, Conservative leader Andrew Scheer.
"Tonight we have put him on notice," Scheer said in Regina, Saskatchewan, of Trudeau. "His leadership is damaged and his government will end soon and when that time comes, we will be ready and we will win.
"We are the government in waiting," added Scheer, 40, whose party won 122 seats.
Trudeau, 47, who has championed diversity as prime minister, was endorsed by former U.S. President Barack Obama in the final stretch of the campaign and is viewed as one of the last remaining progressive leaders among the world's major democracies.
But the son of the late Liberal Prime Minister Pierre Trudeau also had to overcome a sense of fatigue with his government.
U.S. President Donald Trump, whose relationship with Trudeau has been testy at times, congratulated him "on a wonderful and hard fought victory" via Twitter.
The Bloc Quebecois saw its support jump in Quebec, the only place where the separatist party contests elections. It was elected or ahead in 32 seats, more than three times what the party won in 2015.
"Dear Quebecers, I heard your message tonight," said Trudeau, who also addressed voters in two western provinces where Liberals were shut out of seats.
"To Canadians in Alberta and Saskatchewan, know that you are an essential part of our great country. I've heard your frustration and I want to be there to support you. Let us all work hard to bring our country together," he said.
The Greens, who have assailed Trudeau for not doing enough to combat climate change, also made gains on Monday.
The Canadian dollar was little changed after the Liberal win, holding at near three-month highs.
"Markets don't like uncertainty so it will all depend on what coalition they can come up with and how sustainable that will become," said Greg Taylor, portfolio manager at Purpose Investments in Toronto.
"The bigger problem is it seems that Canadians have never been more divided and the next government really needs to work to correct that. Alberta is at risk of a broader separatist movement and that would be a major negative for Canada."
Two Liberal Cabinet ministers lost their seats in western Canada, including veteran Ralph Goodale, the public safety minister. Anger at Trudeau has mounted in the oil-producing region over federal environmental policies that the energy industry says will harm output.
The oil industry's top lobbying group has blamed Trudeau's policies for throttling investment in the sector, and some global energy companies have shed assets in the oil sands region of Alberta, the country's main oil-producing province.
Canada's economy, however, has been on a general upswing in 2019. The Canadian dollar has been the best-performing G10 currency this year, rising more than 4% against its U.S. counterpart, as the economy added jobs at a robust pace and inflation stayed close to the Bank of Canada's 2% target.
The six-week official campaign period was a rough and meandering ride with dirty tactics on both sides in the G7 country.
The liberal image of Trudeau, whose father opened the country to mass immigration, took a severe blow when pictures emerged early in the campaign of him wearing blackface in the early 1990s and in 2001.
Trudeau had already been wrestling with the fallout from accusations he pressured his justice minister to help shield engineering firm SNC-Lavalin Group Inc from corruption charges. In August, a top watchdog said Trudeau breached ethics rules.
Scheer also proved to be a determined opponent, although his hopes for a major breakthrough were dashed.
He had promised to balance the federal budget and eliminate a "carbon tax" on fossil fuels.
"The Tories made a fundamental mistake by being opposed to the carbon tax," said Hugh Segal, who was chief of staff to former Conservative Prime Minister Brian Mulroney.
"I've often heard it said the worst mistake a party can make is to get sucked into its own low expectations of the population," he said.