Trump administration attorneys defended the disputed Keystone XL oil sands pipeline in federal court on Thursday against environmentalists and Native American groups that want to derail the project.

President Barack Obama rejected the 1,800-kilometre line proposed by TransCanada Corporation in 2015 because of its potential to exacerbate climate change.

President Donald Trump revived the project soon after taking office last year, citing its potential to create jobs and advance energy independence.

Environmentalists and Native American groups sued to stop the line and asked U.S. District Judge Brian Morris to halt the project. They and others, including landowners, are worried about spills that could foul groundwater and the pipeline's impacts to their property rights.

Morris did not immediately rule following a four-hour Thursday hearing in federal court in Great Falls.

U.S. government attorneys asserted that Trump's change in course from Obama's focus on climate change reflected a legitimate shift in policy, not an arbitrary rejection of previous studies of the project.

"While the importance of climate change was considered, the interests of energy security and economic development outweighed those concerns," the attorneys recently wrote.

Morris previously rejected a bid by the administration to dismiss the lawsuit on the grounds that Trump had constitutional authority over the pipeline as a matter of national security.

Keystone XL would cost an estimated $8 billion US. It would begin in Alberta and transport up to 830,000 barrels a day of crude through Montana and South Dakota to Nebraska, where it would connect with lines to carry oil to Gulf Coast refineries.

Federal approval is required because the route crosses an international border.

TransCanada, based in Calgary, said in court submissions that the pipeline would operate safely and help reduce U.S. reliance on crude from the Middle East and other regions.

The project is facing a separate legal challenge in Nebraska, where landowners have filed a lawsuit challenging the Nebraska Public Service Commission's decision to approve a route through the state.