A Nebraska court on Wednesday invalidated the governor's decision to allow the controversial Keystone XL pipeline to pass through the Midwestern state, casting uncertainty over the project to link Alberta's oil sands with refineries in Texas.

Nebraska Governor Dave Heineman last year supported legislation that cleared the way for the $5.4 billion pipeline to cross parts of his state.

But some landowners objected to the legislation, saying it sidestepped their rights.

On Wednesday, the District Court of Lancaster County, Nebraska, sided with landowners. Judge Stephanie Stacy ruled that a recent law passed by the state's legislature giving Heineman the decision on the route instead of the state's Public Service Commission was "unconstitutional" and "void."

TransCanada Corp is counting on President Barack Obama to approve its pipeline plan, but supporters had counted on the support of states and landowners as well.

A decision from the White House was not expected before May.

Some Keystone foes said the Nebraska court's decision guaranteed months more of legal wrangling and uncertainty.

"This court decision provides more uncertainty for pipeline proponents, and more time to organize for pipeline opponents," said Dan Weiss, a senior fellow with the Center for American Progress, which opposes the plan.

(Reporting by Patrick Rucker, Valerie Volcovici and Timothy Gardner; Editing by Peter Cooney)