In a significant victory for indigenous groups and environmentalists, Canada's most controversial oil pipeline project has been suspended.
The Federal Court of Appeals has overturned the government's approval of the Trans Mountain oil pipeline.
It said the government failed to adequately address the legal rights of aboriginal people or concerns about oil spills.
The Trans Mountain expansion would nearly triple capacity on an existing line from Edmonton, Alberta, to a port in the Vancouver area for export. It was approved by the federal government in 2016.
In May the government of Justin Trudeau agreed to buy the pipeline from Kinder Morgan Canada Limited for almost $US3.5 billion ($NZ5.2b), betting it would win the court battle and expand Trans Mountain despite fierce political and environmental opposition.
Today's appeals court decision will be a blow to Mr Trudeau who has portrayed himself as a friend to First Nation people and tried to build national support for a carbon emissions reduction plan, even while backing Trans Mountain to support the oil industry.
"It's quite a slap to the government by the court on the grounds of reconciliation with First Nations," said Kathryn Harrison, a professor of political science at the University of British Columbia. "They've committed billions of dollars in taxpayers' funds, doubling down on a project that the courts have just quashed."
The decision will hurt Canada's oil producers, who said the expanded pipeline was needed to address bottlenecks that had sharply reduced prices for their crude.
But opponents of the project are hailing the court ruling.
British Colombia and its capital Vancouver, which would have seen increased oil tanker traffic due to the pipeline, has been at the centre of the protests. Its government has welcomed the decision.
Many First Nation groups too have described it as a victory.
In a statement Coldwater Indian Band Chief Lee Spahan said "Thankfully, the court has stepped in where Canada has failed to protect and respect our rights and our water. Our members will be hugely relieved."
However the government is vowing to fight on.
Canada's Finance Minister Bill Morneau said the pipeline was in the national interest.
He said the government remained "absolutely committed" to building the project.
Mr Morneau said the government needed time to study the ruling but it had the option to take the case to the Supreme Court.