In his four years leading Canada, the Liberal prime minister, Justin Trudeau, has gone to great lengths – at home and abroad – to bolster his environmental credentials. Now, with a federal election looming, he is gambling his parliamentary majority and political future on them.

When Canadians cast their votes next October, they will do so amid standard electoral issues: jobs, the economy and foreign policy. But in a country largely dependent on resource extraction, a pair of politically fractious additions have risen to the top: carbon taxes and pipelines.

“The good news for the prime minister is that when you ask Canadians who they think would make the best prime minister, he still has a comfortable advantage over Conservative leader Andrew Scheer,” said Nik Nanos, a Canadian pollster. “The bad news is that leading up to the next federal election right now, it’s basically a coin toss between the Liberals and Conservatives.”

Canadians have shown an increasing concern for the environment, but in a country largely dependent on resource extraction, the results are often messy.

Earlier in the year, as part of its pan-Canadian climate change strategy, the federal government required all provinces have a minimum level of carbon pricing. For those that fail to do so, the government will implement its own carbon tax, set to begin in July 2019. Already, the levy has fired up Trudeau’s political opponents – at both the provincial and federal level.

But the prime minister had been forced to fend off barbs from critics – including the left-of-centre New Democratic party and Indigenous communities, that any environmental goodwill he might have earned through his carbon tax has been sullied by the support for – and subsequent nationalisation of – an oil pipeline. “The only true test of a climate change plan, after all, is whether carbon is going up or down,” said the NDP leader, Jagmeet Singh, in a statement about his frustrations with the Trans Mountain Pipeline, which runs from Alberta to the British Columbia coast.

The result for Trudeau is a tricky path forward as he heads off attacks that he has done too little on the environment – or too much.

“Trudeau has moved from having an environment that was friendly and pliant to one that is more combative and hostile,” said Nanos, pointing to a string of shifts to Conservative – or right-of-centre – provincial governments across the country since Trudeau was elected in 2015. Doug Ford, Ontario’s premier, has repeatedly called carbon pricing “the worst tax ever” and at least five provinces have banded together to fight the tax in the courts, a battle legal experts believe they will lose.

Along with their provincial counterparts, the federal Conservatives have pledged to repeal any carbon taxes, with Scheer dismissing the policy as an “election gimmick”. This fight comes amid reports that Canada is not on pace to meet its 2030 climate goals.

Steel pipe for the pipeline construction of Canada’s Trans Mountain expansion project sits on rail cars at a site in Kamloops, British Columbia. Photograph: Dennis Owen/Reuters

“The opposition or the politicians will convince people that the carbon price is hurting them, even though that’s a lie,” said Mark Jaccard, professor of sustainable energy at Simon Fraser University.

Jaccard, who has also served as a policy analyst, has previously warned respective governments that carbon taxes – while effective at reducing emissions – are politically difficult to sell and often not as effective as other policy options. He points out that the biggest emissions reductions in Canada came from the Ontario government’s closure of coal plants. The recent plan to close all of Canada’s coal plants by 2029 will have a far greater impact than a carbon tax – yet the tax will probably remain at the centre of the discussion.

The tax could end up being particularly appealing from an electoral standpoint, said Nelson Wiseman, a professor of political science at the University of Toronto. All proceeds from the levy will be remitted back to households in the form of a cheque, the first of which will arrive in July – a date Wiseman suspects will be close enough to the election that people will take notice.

But Wiseman, who has studied the country’s elections for generations, cautions: “We’re still a long way off. And things can change on a dime in politics.”