BISMARCK — A federal judge has ordered the controversial Dakota Access Pipeline to shut down by Aug. 5 — a major victory for the Standing Rock Sioux Tribe and a significant setback for North Dakota's already-floundering oil industry.

U.S. District Judge James Boasberg wrote on Monday, July 6, that the pipeline must be emptied of all oil within 30 days and will remain shut while the Army Corps of Engineers finishes an environmental review that Boasberg estimates will take 13 months.

A news release from pipeline operator Energy Transfer Partners says the company will file a motion to stay the decision, and if not granted, it will appeal to a higher court. The company says it is confident the pipeline will remain on-line throughout the legal proceedings to come.

The original $3.8 billion pipeline project, which crosses under the Missouri River near the tribe's reservation, prompted protests from tribal members and climate activists in 2016 and 2017. The 1,172-mile pipeline has been transporting crude oil from the Bakken formation in western North Dakota to central Illinois since May 2017.

Standing Rock Chairman Mike Faith did not immediately respond to a request for comment, but he celebrated the shift in the tribe's long legal battle against the pipeline in a news release.

"Today is a historic day for the Standing Rock Sioux Tribe and the many people who have supported us in the fight against the pipeline," Faith said. “This pipeline should have never been built here. We told them that from the beginning.”

The company questioned whether Boasberg has the authority to shut down the pipeline and noted that the economic implications of the decision are "too big to ignore."

"Shutting down this critical piece of infrastructure would throw our country’s crude supply system out of balance, negatively impact several significant industries, inflict more damage on an already struggling economy, and jeopardize our national security," spokeswoman Lisa Coleman said.

Spokespeople for the Army Corps of Engineers did not immediately respond to requests for comment.

Boasberg ruled in March that the Corp's previous environmental review did not adequately assess the impact of the pipeline on the tribe and others in its path, noting that too many questions remained about leak detection, the operator's safety record and the possibility of a worst-case spill. Boasberg said at the time he would consider briefs from both sides and decide later on whether the pipeline could continue operating while the review was underway.

"Although mindful of the disruption such a shutdown will cause, the Court now concludes that the answer is yes," Boasberg wrote in his decision Monday.

The Standing Rock and Cheyenne River Sioux tribes originally sued the Army Corps in 2016, contending that the pipeline's crossing under Lake Oahe, a dammed portion of the Missouri River, would jeopardize the tribes' water resources. Many tribal members have said they also feel a spiritual and cultural connection to the water.

The tribes' fight against the pipeline drew support from around the globe in 2016 as protesters camped out for months near the site of the proposed pipeline crossing by the Standing Rock Reservation in an effort to prevent the project from going forward. The protests dwindled during the harsh winter, and police cleared out remaining protesters in February 2017.

President Barack Obama's administration blocked a final permit needed to complete the project in late 2016, but President Donald Trump pushed through approval of the project upon taking office the following January.

Low oil prices caused by the coronavirus pandemic and a trade war between Russia and Saudi Arabia rocked western North Dakota's Oil Patch in March. The state's second-largest industry has struggled to recover from massive layoffs and production cuts.

The pipeline can carry up to 570,000 barrels of crude oil per day, and Energy Transfer Partners has secured state approval to expand capacity to 1.1 million barrels per day. The depressed industry and the latest court ruling could put the expansion project in doubt.

North Dakota Petroleum Council President Ron Ness called Monday's decision "very disturbing," comparing the potential impact of shutting down the pipeline to closing the BNSF Railway for farmers. Ness, whose organization represents more than 650 oil and gas-related companies, said he expects Energy Transfer to appeal the decision, but he noted that if it holds, oil producers will have to go back to transporting their product via more unsafe and less profitable methods like rail and truck.

Republican Gov. Doug Burgum, who has supported the pipeline, said the decision could have devastating effects on the state's economy. He added that if a single judge could shut down a "state-of-the-art pipeline project," it would have a chilling effect on the country's ability to build and improve critical infrastructure.

The state's all-Republican congressional delegation also denounced the decision. Sen. Kevin Cramer said the pipeline shutting down would have "devastating consequences to North Dakota and to America’s energy security."

Sen. John Hoeven touted the pipeline's advanced technology and clean record in three years of operation. He added that the ruling comes at "a very difficult time" for the industry, but he said he expected a forthcoming appeal from the company. Rep. Kelly Armstrong called the decision "irresponsible and wrong-headed," noting that it ignores all precedent and provides a win for radical environmentalists.

Climate activists and Native American groups welcomed Monday's decision as a step in the right direction. Former Democratic Vice President Al Gore said in a tweet the ruling is a "big win for climate." The Sierra Club, an American environmental organization, declared the decision a major victory for the Standing Rock and Cheyenne River Sioux tribes.

Cheyenne River Sioux Tribal Chairman Harold Frazier embraced the ruling, saying that the court finally confirmed the illegality of the pipeline's operation. The tribe's reservation lies along the Missouri River in north-central South Dakota.

"It is time to (put) people before profit and seriously consider the impact of not only this project, but the harm that this project brings to our land and planet," Frazier said in a news release. "It is with extreme gratitude that I acknowledge the work, sacrifice and perseverance of every water protector involved in this fight."

Reporters Michelle Griffith and Sarah Mearhoff contributed to this report.