OTTAWA — An increasingly bitter dispute between two of Canada’s largest provinces over expansion of a pipeline for tar sands oil is pitting environmentalists against business and posing a major political challenge for Prime Minister Justin Trudeau.

At the heart of the battle are plans to triple the capacity of the 65-year-old Trans Mountain pipeline, allowing more crude to flow from northern Alberta to the port of Burnaby, B.C. , adjacent to Vancouver.

The province of Alberta says the $5.7 billion project, which the Trudeau government approved in late 2016, is crucial to the growth of its oil industry, which is increasingly dependent on tar sands extraction facilities. In Alberta, tar sands are mined in massive open-pit operations and must be partially processed to create a crude known as diluted bitumen before it is sent by pipeline or rail to be refined into gasoline and other petroleum products. Because of capacity constraints and roadblocks facing several other pipeline projects, the province is finding it increasingly difficult to get its oil to market.

Next door, in the province of British Columbia, the eco-friendly government of Premier John Horgan is challenging the pipeline expansion in court, claiming better protection of the province’s scenic coastline is needed in case of a tanker spill. That has enraged Alberta, which has vowed to retaliate by introducing legislation to “turn off the taps” of diesel and gasoline to British Columbia, vital to that province’s economy.

“On the one hand, they don’t want our oil, and on the other hand, they are suing us to give them our oil,” Alberta Premier Rachel Notley said this week after British Columbia hit back with another lawsuit and said it will seek an injunction to stop Alberta from cutting off its fuel supply. Earlier this year, Alberta also threatened to retaliate against its neighbor by banning the sale of British Columbian wine in the province.

Trudeau finds himself in the middle of the fray. Although he came to power in 2015 as an environmental champion and quickly signed Canada into the Paris climate accord, Trudeau has also been an outspoken backer of the Trans Mountain project, an affiliate of Houston-based Kinder Morgan.

“There is no choice between what is good for the climate and what is good for the economy,” Trudeau told reporters recently in Calgary, Alberta, capital of Canada’s oil industry. “They have to go together.”

He insisted: “This pipeline is in the national interest and it will get built.”

But the legal drama has put the expansion project in jeopardy. In April, Kinder Morgan announced it was suspending all nonessential work on the pipeline and would decide by May 31 whether to pull the plug on the 715-mile expansion.

The Trudeau government has responded by offering to compensate Kinder Morgan or other potential investors for any “unnecessary delays” on the project and has hinted that if Kinder Morgan pulls out of the project, other private-sector firms would be willing to fill the void.

“Justin Trudeau is trying to thread a very, very careful needle and the eye of this needle is exceedingly small,” said Shachi Kurl, executive director of Angus Reid Institute, a Vancouver-based polling firm.

Kurl said that Trudeau needs to back the pipeline to assure the business community that Canada is a safe place to invest, and to assert federal jurisdiction over the bickering provinces.

Politically, Trudeau’s Liberal Party looks as if it has more to lose than to gain. Even though Trudeau is backing Alberta in the dispute, the province is solidly in the hands of the opposition Conservative Party federally and that’s unlikely to change. In British Columbia, on the other hand, Trudeau’s pro-pipeline stance is likely to lose his party support in the Vancouver area, where the project is unpopular because of opposition to increased tanker traffic.

Overall, a slim majority of Canadians back the pipeline project and that support has been growing, Kurl said.

The Canadian tar sands industry has been on a tear in recent years, adding major capacity to extraction plants in northern Alberta and attracting migrants from across the country to high-paying jobs in the sector. But the scarring of the landscape by the industry’s open-pit extraction methods and its high carbon emissions have made it an easy target for environmentalists.

With Alberta far from tidewater, getting the oil to market has proved an increasing challenge. Two other Canadian pipeline projects, Northern Gateway and Energy East, were abandoned because of regulatory and political obstacles, and the cross-border Keystone XL project remains delayed because of opposition in Nebraska and South Dakota.

As oil producers struggle to ship Canadian crude, the price of oil has become deeply discounted.

The Bank of Nova Scotia, one of Canada’s largest commercial banks, said in a recent study that discounts on Canadian oil will cost the oil sector several billion dollars in 2018.

“Pipeline approval delays impose clear, demonstrable and substantial economic costs on the Canadian economy,” said the bank’s chief economist, Jean-Francois Perrault. “The elevated discounts come with a deep economic cost and represent to a large degree a self-inflicted wound.”

But Greenpeace, one of several environmental groups opposed to Trans Mountain, has pushed back on that assessment. “Climate change also imposes clear, demonstrable and substantial economic costs on the Canadian economy, and these costs are only going to get worse,” Greenpeace official Keith Stewart said.

In addition to the environmental opposition to the project, several indigenous groups are attempting to block the expansion in court, insisting that they should have the final say over the pipeline route.

George Hoberg, a political scientist at University of British Columbia, said that even if the project gets the go-ahead from the courts, the opposition won’t go away.

“I’m certain there will be significant resistance on the ground,” Hoberg said. “I would be very surprised if it doesn’t end up with civil disobedience.”