The Federal Court has suspended Alberta's turn-off-the-taps legislation, aimed in part at the embattled Trans Mountain pipeline extension, granting British Columbia a temporary injunction blocking the law until the courts can decide whether it is valid.

The legislation was passed — but never used — by Alberta's former NDP government to give its energy minister the power to pinch oil and crude exports to other provinces. It was perceived as a move that would punish B.C. over its continued challenges to the Trans Mountain pipeline expansion.

B.C. challenged the law in court this spring, saying the bill was unconstitutional. Federal Court Justice Sébastien Grammond said Tuesday the law raised a "serious issue" that could hurt British Columbians.

"I find that the irreparable harm that British Columbia would suffer if the injunction is not granted far outweighs any inconvenience that the injunction might impose on Alberta," read the decision from Grammond.

In the wake of the decision, Alberta's minister of energy is banned from "turning off the taps" until a full review to determine whether the legislation is constitutional is completed.

Provinces react

B.C. Attorney General David Eby addressed reporters in Vancouver after the decision was posted Tuesday morning, saying he was pleased with the order.

"That is an important win for British Columbia today," Eby said. "Certainly, having the injunction in place provides some relief to British Columbians."

Watch: David Eby says there's no timeline on a resolution for Bill 12

B.C. Attorney General David Eby says his government's understanding of the constitution is that Alberta shouldn't be allowed to restrict the flow of its product to other provinces as punishment. 1:34

The legal battle is part of the fallout over the Trans Mountain expansion project, which has been subject to several court challenges from provincial and municipal governments as well as Indigenous communities and environmental groups.

Bill 12 requires exporters to obtain licences, and gives Alberta Energy Minister Sonya Savage power to decide how much fuel is exported, how it's transported — by pipeline, rail or tanker truck — and whether direct shipments should be stopped altogether.

B.C. Premier John Horgan said he was pleased the court found the bill unconstitutional.

"I'm grateful now that we don't have that threat, which was a significant threat to our economy and to our people," he said. "It's no longer in play."

Horgan said he hopes he and his Albertan counterpart, Jason Kenney, continue to develop a positive working relationship between the two provinces.

Kenney said his government intends to study the ruling and change the legislation if necessary.

"If we think amendments are necessary to comply with the court's view, then we will make those amendments," said Kenney.

"We think there may be ways to effectively narrow the scope of the bill in a way that would be compliant with the legal concerns that have been raised."

Watch: Jason Kenney reacts to suspension of Bill 12

Alberta Premier Jason Kenney says he's confident B.C. will continue to respect the decision of the courts and his government will make amendments to Bill 12 if necessary. 2:24

Alberta's NDP leader and former premier Rachel Notley said Kenney has robbed Albertans of an important tool to respond to B.C. by proclaiming the bill too early.

In their handover meeting after the election, she says she told Kenney not to proclaim it until he was ready to use it.

The bill was proclaimed into law after Kenney was sworn in on April 30.

"He ignored that advice in order to play politics," said Notley.

B.C.'s argument, Alberta's defence

B.C. said the act would affect interprovincial trade, which is under Ottawa's jurisdiction. The province also argued the only purpose of Alberta's act was to cut off exports to the West Coast "in retaliation for its perceived opposition" to the pipeline project.

A lawyer for the Alberta government insisted the legislation was not meant to hurt B.C., despite political rhetoric suggesting otherwise.

Alberta had asked the Federal Court to have B.C.'s application thrown out, saying the western province was acting prematurely, considering the law had never been used. Grammond rejected that stance.

The justice also said there was a lack of "clear" evidence an injunction would hurt Alberta.

The federal government bought the existing Trans Mountain pipeline last year for $4.5 billion after its original builder, Texas-based Kinder Morgan, threatened to walk away from its expansion in part because of B.C.'s resistance.

Hearings on B.C.'s challenge to Bill 12 will continue in Federal Court.