The first results are expected starting at 2300 GMT, a few hours before voting wraps up in westernmost British Columbia at 0200 GMT Tuesday
After 40 days of campaigning, neither of the parties, Liberal or Conservative, is expected to secure an absolute majority of seats in parliament
Canadians began voting in a general election Monday, with surveys predicting that Prime Minister Justin Trudeau's Liberal Party could return with a weakened minority government or lose his grip on power entirely.
The Liberals and the Conservatives, led by Andrew Scheer, were set for a near dead heat with pundits calling it one Canada's closest elections ever.
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 a suburb of Vancouver after whistle-stops in Ontario, Manitoba and Alberta.
"We need to unite as citizens. We need to unite as a planet."
Trudeau's star has dimmed since winning in a 2015 landslide that echoed the wave of support that carried in his bullish, flamboyant late father Pierre in 1968.
His image has been tainted by ethics lapses in the handling of the bribery prosecution of an engineering giant, while his campaign was rocked by the emergence of old photographs of him in blackface make-up.
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 was to cast a ballot in Regina, Saskatchewan.
Main parties both struggle
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 last 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."
The campaign has been described as one of the nastiest ever, with attack ads including 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" and Scheer called the prime minister a "compulsive liar," "a phony and a fraud."
Trudeau defends record
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 with Europe, Pacific nations and North American neighbors.
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 said in a tweet.
The Conservatives, meanwhile, have stood alone among all of the parties in pledging austerity measures to return to a balanced budget within five years.
Scheer was shaken late in the campaign 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 has come back from a ruinous 2015 election result, tapping into lingering Quebec nationalism to challenge the Liberals' dominance in the province.
The Bloc and NDP have said they would not prop up the Tories if they secure a minority.
So who will govern may still be unclear for weeks after the polls close during alliance negotiations that could keep Trudeau in office even if his party loses.
This story has been published from a wire agency feed without modifications to the text. Only the headline has been changed.