A Nebraska judge on Wednesday struck down a law that allowed the Keystone XL pipeline to proceed through the state, a setback for the project that would carry oil from Canada to Texas refineries.

Lancaster County Judge Stephanie Stacy issued a ruling that invalidated Nebraska Gov. Dave Heineman's approval of the route. Stacy agreed with opponents' arguments that a law passed in 2011 improperly allowed Heineman to give TransCanada eminent domain powers within the state. Stacy said the decision should have been made by the Nebraska Public Service Commission, which regulates pipelines and other utilities.

Heineman said Wednesday that state Attorney General Jon Bruning is appealing the ruling.

The ruling could cause more delays in finishing the pipeline. State officials who defended the law are likely to appeal to the Nebraska Supreme Court. Nebraska lawmakers may have to pass a new pipeline-sitting law to allow the Public Service Commission to act.

If they do, it's not yet clear how long the five-member PSC might take on the issue or whether it would approve the pipeline. Staff members were still reviewing the ruling Wednesday, said Angela Melton, the commission's attorney.

A spokesman for pipeline developer TransCanada said company officials were disappointed and disagreed with the decision, which came in a lawsuit filed by three Nebraska landowners who oppose the pipeline. The company planned to review the ruling before deciding how to proceed.

"TransCanada continues to believe strongly in Keystone XL and the benefits it would provide to Americans — thousands of jobs and a secure supply of crude oil from a trusted neighbor in Canada," said spokesman Shawn Howard.

Dave Domina, the landowners' attorney, said in a statement that the ruling means TransCanada has "no approved route in Nebraska."

"TransCanada is not authorized to condemn the property against Nebraska landowners. The pipeline project is at standstill in this state," he said.

The Keystone XL would carry 830,000 barrels of oil daily from Canada to Texas Gulf Coast refineries. In its latest environmental analysis, the U.S. State Department raised no major environmental objections to the $7 billion pipeline. Opponents disagree, saying the pipeline threatens ground- and surface water and would disrupt soil in the Nebraska Sandhills, a region of grass-covered dunes used as ranchland.

The Nebraska Legislature in 2011 gave Heineman the ability to approve the route after landowners complained that the pipeline posed a threat to the Sandhills. Heineman approved a new route that went around an area designated as the Sandhills, although opponents insist it still traverses the delicate soil.

Domina said the ruling means that the governor's office has no role to play in the pipeline, and decisions within the state must be made by the Public Service Commission. The commission was created in 1890s to prevent governors from granting political favors to railroad executives who wanted to expand through private property.

The decision on a federal permit still rests with President Obama.

Pipeline opponents called Wednesday's ruling a victory for landowners.

"TransCanada learned a hard lesson today: Never underestimate the power of family farmers and ranchers protecting their land and water," said Jane Kleeb, executive director of the anti-pipeline group Bold Nebraska.

The Associated Press contributed to this report.