A Canadian court has overturned the approval of Enbridge Inc.s Northern Gateway oil pipeline, adding another steep obstacle to a project fiercely opposed by environmentalists and many aboriginal groups.

The Federal Court of Appeal ruled in a 2-to-1 decision, released on June 30, that the government had failed in its duty to consult with aboriginal groups on the project, and sent the matter back to Prime Minister Justin Trudeau's cabinet for a "prompt redetermination."

Calgary, Alberta-based Enbridge said in a statement that it remains "fully committed" to building the CA$7.9 billion (US$6.1 billion) pipeline, and that it was working with partners, including aboriginal groups who support the project, to determine the next steps.

Canada's former Conservative government in 2014 approved Northern Gateway, which would carry oil from the Alberta oil sands to a port in northern British Columbia for export. Its construction was subject to more than 200 conditions.

After the approval, numerous British Columbia aboriginal communities, along with environmental groups, filed lawsuits seeking to overturn the decision.

In its 153-page judgment, the court determined that Canada's consultation with aboriginal communities, also known as First Nations, was "brief, hurried and inadequate." It said the government failed to grapple with their concerns and had not shown any intention to correct any errors or omissions in the original regulatory panel review.

"Missing was a real and sustained effort to pursue meaningful two-way dialogue. Missing was someone from Canada's side empowered to do more than take notes, someone able to respond meaningfully," the judges wrote.

The court also noted that it would have taken the government little time and effort to meaningfully engage with First Nations, but that this was not done. Trudeau's cabinet will now have to fulfill that duty before a new permit can be issued.

In April, Trudeau said he opposed the pipeline. Last year, his freshly elected Liberal government said it would implement a moratorium on oil tanker traffic along the northern coast of British Columbia, a policy seen as making the pipeline unfeasible.

The court's decision was heralded by environmental groups and First Nations, which said the decision "shuts the door" on the 1,177-kilometer (730-mile) pipeline.

"This pipeline will never be built. This is a victory," Sven Biggs, a representative of one of the environmental groups in the lawsuit, said in a statement.

Enbridge's shares closed up 0.2% at CA$54.73 on June 30 in Toronto.

(US$1 = 1.2949 Canadian dollars)