GREAT FALLS, Mont. — A federal judge on Wednesday rejected a bid by the Donald Trump administration to dismiss a lawsuit that challenges a presidential permit for the proposed Keystone XL oil pipeline from Canada.

U.S. District Judge Brian Morris in Great Falls, Montana, dismissed U.S. Justice Department arguments that the court had no authority to second-guess the cross-border permit that was issued by the State Department.

Morris also rejected motions by TransCanada Corp., the company behind the project, to dismiss the suit.

Conservation groups and Native American organizations contend in the lawsuit that an environmental review of the project completed in 2014 was inadequate. They’ve asked Morris to revoke the permit, which was based on the review and issued in March.

The 1,179-mile (1,800-kilometer) pipeline would transport Canadian crude through Montana and South Dakota to Nebraska, where it would connect with lines to carry oil to Gulf Coast refineries.

President Barack Obama’s administration rejected the project in 2015, but it was revived in March under Trump. The president insists it will create jobs and lead to greater energy independence.

In seeking to dismiss the suit, government attorneys had argued that Trump had constitutional authority over matters of foreign affairs and national security.

Morris rejected the notion that any potential court injunction — or even review of the permitting process — would illegally infringe on the president’s authority.

Morris cited a decision by the 9th U.S. Circuit Court of Appeals in a case concerning a federal visa exchange program. The circuit court’s decision “has made clear that the State Department cannot avoid judicial review simply by invoking its consideration of ‘foreign policy’ or ‘security’ factors,” Morris wrote.

Both the Justice Department and TransCanada said Wednesday they were reviewing the decision.

“Our environmental laws should never be undercut by the interests of a private foreign company, and the court’s decision today solidifies that,” Hannah Adams, deputy director of the activist group and co-plaintiff Bold Alliance, said in a statement.

On Monday, Nebraska regulators approved a pipeline route through that state, though the vote is likely to face court challenges. The route is not one preferred by TransCanada, and it could require more time for government agencies to study the changes.

TransCanada has said that it would announce by early December whether to proceed with the pipeline — which would carry an estimated 830,000 barrels of oil a day — and would take into account the Nebraska decision and whether it has lined up enough long-term contracts to ship oil.

Keystone XL would expand the existing Keystone pipeline network that went into service in July 2010. The current pipeline runs through North Dakota, South Dakota, Nebraska, Kansas, Oklahoma and Texas and extends east into Missouri and Illinois.