Canadians voted Monday in what pundits called one of the country's closest elections ever, leaving the future of Prime Minister Justin Trudeau in doubt.
Surveys predicted Trudeau's Liberal Party could return with a minority government or lose its grip on power entirely.
The Liberals and the Conservatives, led by Andrew Scheer, were set for a near dead heat.
Polls opened at 1100 GMT in the Atlantic province of Newfoundland, the first of the country's six time zones. About 27.4 million Canadians are eligible to elect 338 members of parliament.
The first results are expected starting at 2300 GMT, a few hours before voting wraps up in westernmost British Columbia.
After 40 days of campaigning, neither of the two parties that have led Canada since Confederation in 1867 was expected to secure an absolute majority of seats.
At final campaign stops in British Columbia on Sunday, former golden boy Trudeau made an emotional appeal for voters to let him build on his first-term achievements.
He warned against Scheer's pledged rollback of environmental protections, including a federal carbon tax that discourages the use of large amounts of fossil fuels.
"We need a strong, progressive government that will unite Canadians and fight climate change -- not a progressive opposition," Trudeau told a rally in suburban Vancouver.
"We need to unite as citizens. We need to unite as a planet."
Trudeau's star has dimmed since winning a 2015 landslide that echoed the wave of support which in 1968 carried to power his flamboyant late father Pierre, who is considered the father of modern Canada.
The younger Trudeau's image has been tainted by ethics lapses in the handling of the bribery prosecution of engineering firm SNC-Lavalin, while the emergence of old photographs of him in blackface makeup rocked his campaign.
Surging social democrats and resuscitated Quebec separatists have also chipped away at Liberal support.
Trudeau, accompanied by his wife and children, voted in the morning in Montreal while Scheer, also with his family, cast a ballot in Regina, Saskatchewan in the late afternoon.
If Trudeau hangs on, it will be because Scheer has struggled to win over Canadians with his bland minivan-driving dad persona and a throwback to the thrifty policies of past Tory administrations.
Canadians "cannot afford" a Liberal government propped up by the third-place New Democratic Party (NDP), Scheer said at the end of a marathon final push from the Atlantic to Pacific oceans.
"We can only imagine what the NDP's price would be to keep Justin Trudeau in power," he said.
"Whatever it is, we know Trudeau would pay any price to stay in power and he'd use your money to do it."
NDP leader Jagmeet Singh, a leftist former criminal defense lawyer, is the first non-white leader of a national political party, and could emerge as possible kingmaker.
The campaign has been described as one of the nastiest ever. Attack ads included false accusations that Liberals would legalize hard drugs and that the Tories would allow the proliferation of assault weapons.
At one rally, Trudeau was forced to wear a bulletproof vest.
Along the bruising way, Trudeau and Scheer traded barbs.
Trudeau evoked the bogeymen of past and current Tory parties fostering "politics of fear and division" while Scheer called the prime minister a "compulsive liar," "a phony and a fraud."
Outside polling stations, Canadians told AFP they had wished for a more positive campaign focused on issues.
"I deplored the cheap shots during the campaign. I think we're better than that," said Andree Legault in Montreal.
"What Trudeau's done the last four years, I think it's got most of us a little angry," said Jade Schultz in Regina, "so I just think we need someone new in there."
Trudeau defended his record: a strong economy and low unemployment, legal cannabis, the resettlement of 60,000 Syrian refugees, doctor-assisted deaths, a public inquiry into missing and murdered indigenous women, and free trade deals.
Former US president Barack Obama endorsed Trudeau, calling him an "effective leader who takes on big issues like climate change."
"The world needs his progressive leadership now," Obama tweeted.
The Conservatives have stood alone among all of the parties in pledging austerity measures to return to a balanced budget within five years.
Late in the campaign, 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 party has situated itself to the right of the Conservatives and could draw votes away.
On the left, the Bloc Quebecois has come back from a ruinous 2015 election result, tapping into lingering Quebec nationalism.
The Bloc and NDP have said they would not prop up the Tories if they secure a minority.
Ottawa, Canada | AFP