In a stunning blow, the Federal Court of Appeal has quashed the government’s approvals to build the Trans Mountain expansion project — a major victory for Indigenous groups and environmentalists opposed to the $7.4-billion project.

In the decision released Thursday, and written by Justice Eleanor Dawson, the court found the National Energy Board’s assessment of the project was so flawed that it should not have been relied on by the federal cabinet when it gave final approval to proceed in November 2016.

The certificate approving construction and operation of the project has been nullified, leaving the project in legal limbo until the energy regulator and the government reassess their approvals to satisfy the court’s demands.

In effect, the court has halted construction of the 1,150-kilometre project indefinitely.

Amid uncertainty, Kinder Morgan agreed to sell the existing pipeline and the expansion project to the federal government this spring. The company’s shareholders approved the sale Thursday morning in Calgary in a previously scheduled vote held just after the court’s decision was released.

Now, the Liberal government is the owner of a proposed pipeline project that could be subject to years of further review.

Finance Minister Bill Morneau said in a tweet that the federal government is reviewing the decision. He is expected to speak to reporters in Toronto on Thursday afternoon.

In its initial study of the project, the NEB found that the pipeline would not cause significant adverse environmental impacts.

But the court has determined that conclusion is bogus because it did not assess the impacts of marine shipping — increased tanker traffic that would result from the expanded pipeline — on the environment and southern resident killer whales in the waters around the line’s shipping terminal.

The appellate court also found that the federal government did not adequately, or meaningfully, consult with Indigenous people and hear out their concerns after the NEB issued its report recommending that cabinet approve the project.

The court has ordered the federal government redo its Phase 3 consultation.

“Only after that consultation is completed and any accommodation made can the project be put before the Governor in Council (cabinet) for approval,” the decision reads.

“The duty to consult was not adequately discharged in this case.”

Thus, the court is ordering cabinet to direct the NEB to reconsider its approval of the project and remedy some of the concerns raised by the court before cabinet can give the final go-ahead for construction.