A federal ruling blocking the Trump administration’s approval of the Keystone XL pipeline further clouds the future of a project that has faced a decade of delays due to fevered opposition from environmentalists, landowners and Native American groups.

U.S. District Judge Brian M. Morris ruled Thursday night that President Trump’s 2017 cross-border permit of the pipeline expansion by TransCanada Corp. hadn’t considered all impacts as required by federal law, and that construction couldn’t move forward until a supplemental environmental...