A Canadian court on Aug. 30 overturned approval of the Trans Mountain oil pipeline expansion, ruling that Ottawa failed to adequately consider aboriginal concerns, putting the future of the $5.71 billion project in jeopardy.

The decision is a blow to Prime Minister Justin Trudeau's government, which agreed in May to buy the pipeline from Kinder Morgan Canada for C$4.5 billion, and to the country’s oil sector. Oil producers say the expanded pipeline is needed to address bottlenecks that have sharply reduced prices for their heavy crude.

The Federal Court of Appeal ruled that the National Energy Board (NEB) regulator wrongly narrowed its review of the project to exclude related tanker traffic. Since that is a major concern of some aboriginal people, the federal government therefore was not seen to have adequately consulted First Nations, as required by law, said Andrew Leach, associate professor of business economics at University of Alberta.

“The big takeaway is the duty to consult (indigenous people) is still the most important step in any major project,” Leach said.

Trudeau has portrayed himself as a friend to aboriginal people and tried to build national support for a carbon emissions reduction plan, even while backing Trans Mountain to support the oil industry.

“Thankfully, the court has stepped in where Canada has failed to protect and respect our rights and our water,” Coldwater Indian Band Chief Lee Spahan said in a statement. “Our members will be hugely relieved.”

Canada has the option to appeal the ruling to the Supreme Court.

The court’s ruling is likely to amplify sentiments expressed by oil producers, such as Suncor Energy Inc., that they would hold off on further major investments in Canada's oil patch until regulatory challenges abated.

Shares of Canadian oil producers fell in Toronto, led by a 6% decline by MEG Energy Corp., a heavy oil producer that is especially hurt by price discounts connected to clogged pipelines.

Canada agreed to buy the pipeline from Kinder Morgan Canada, betting it would win the court battle and be able to build an expansion, which faces fierce political and environmental opposition.

The expansion would nearly triple capacity on an existing line from Edmonton, Alberta to a port in the Vancouver area for export and was approved by the federal government in 2016. Alberta oil companies say the pipeline is needed to ease transport challenges and allow them to fetch better prices.