(Bloomberg) -- Prime Minister Justin Trudeau’s bid to press ahead with construction of the Trans Mountain pipeline suffered a major setback after a Canadian court nullified approval of the project.

The Federal Court of Appeal ruled Thursday that the regulatory review of the pipeline expansion was “impermissibly flawed” because it excluded project-related tanker traffic. In addition, the court also found the government failed to fulfill its legal duty to consult indigenous people.

The decision effectively halts construction of the conduit, which has been seen as a key project for Canadian oil-sands producers suffering through lower relative prices for their crude due mainly to a lack of pipelines.

It’s also a major headache for Trudeau, whose government is purchasing the C$4.5 billion ($3.5 billion) pipeline from Kinder Morgan Inc. in order to ensure its construction. About half an hour after the court issued its ruling, Kinder Morgan Canada shareholders, meeting in Calgary, voted almost unanimously to proceed with the sale.

Shares of Canadian oil companies plunged on the prospect that the pipeline shortages that have weighed on the price of their crude will continue. The S&P/TSX energy index dropped as much as 1.1 percent following the ruling. Among the top decliners were oil-sands companies like MEG Energy Corp., which slid as much as 8.1 percent, and Cenovus Energy Inc., which dropped as much as 5.6 percent. Kinder Morgan Canada shares rose 0.8 percent to C$16.99 as of 12:08 p.m. in Toronto.

‘Deep Discounts’

Canadian heavy oil prices fell to a $31 a barrel discount to West Texas Intermediate futures this year, the biggest discount since 2013. Three projects that could support prices aren’t scheduled be fully operational until the next decade, including Trans Mountain, Enbridge Inc.’s Line 3 and TransCanada Corp.’s Keystone XL.

“We have seen the issue this year: deep discounts and that’s affecting the pace companies are sanctioning projects,” Kevin Birn, a director on the North American crude oil markets team at IHS Markit, said in a phone interview. “We have got three pipes in the race right now. You need at least two of them to resolve the current issues.”

In addition to faulting the National Energy Board report on which the government based its approval, the court said Canada “fell well short of the minimum requirements imposed by the case law of the Supreme Court” at the last stage of the consultations with indigenous people.

A redo of consultations could mean the restart of at least an 18-month process, analysts say. The government has discretion to impose a timeline on the revised approval process.

Finance Minister Bill Morneau will address the ruling in a 1:15 p.m. press conference in Toronto. “We have received the ruling by the Federal Court of Appeal, and are taking the appropriate time to review the decision,” he said on Twitter after the court decision.

The Trans Mountain expansion would nearly triple the capacity of the six-decade old line, helping carry almost 600,000 more barrels of oil and fuels a day to the Pacific Coast, where they could be loaded onto tankers and shipped to markets in Asia.

The legal challenge had been brought by First Nations, the City of Vancouver and others, who say they weren’t adequately consulted on the National Energy Board’s approval of the project. The government can appeal the decision.

(Updates throughout.)

--With assistance from Erik Hertzberg.

To contact the reporters on this story: Chris Fournier in Ottawa at cfournier3@bloomberg.net;Kevin Orland in Calgary at korland@bloomberg.net;Robert Tuttle in Calgary at rtuttle@bloomberg.net

To contact the editors responsible for this story: Theophilos Argitis at targitis@bloomberg.net, Stephen Wicary, Carlos Caminada

©2018 Bloomberg L.P.