WASHINGTON — In a significant victory for the Standing Rock Sioux Tribe, a federal judge on Wednesday ordered a sweeping new environmental review of the Dakota Access Pipeline.

The pipeline, which runs from North Dakota to Illinois, has been carrying oil for nearly three years and has been contested by environmental groups and Native American tribes who live near it. President Trump sought to keep the project alive.

The ruling by United States District Judge James E. Boasberg found that the pipeline’s “effects on the quality of the human environment are likely to be highly controversial” and that the federal government had not done an adequate job of studying the risks of a major spill or whether the pipeline’s leak detection system was adequate.

He ordered the United States Army Corps of Engineers, which granted the permits for the pipeline, to conduct a more extensive environmental impact statement.