A federal judge ruled Friday against the Standing Rock Sioux Tribe’s request for a preliminary injunction to halt construction on the Dakota Access crude-oil pipeline that the tribe says endangers sacred burial grounds and could threaten its water supply from Lake Oahe, a dammed section of the Missouri River.

But in a development that stunned even the tribe’s lawyers, the decision by District Judge James Boasberg was put on hold by a federal order to stop construction near the tribe’s reservation until the Army Corps of Engineers can revisit its previous decisions in the disputed portion.

“We appreciate the District Court’s opinion on the U.S. Army Corps of Engineers’ compliance with the National Historic Preservation Act. However, important issues raised by the Standing Rock Sioux Tribe and other tribal nations and their members regarding the Dakota Access pipeline specifically, and pipeline-related decision-making generally, remain,” read a joint statement issued by the Army, as well as the Justice and Interior departments.

The fight is being waged over the 1,172-mile Dakota Access pipeline that runs through North and South Dakota, Iowa and Illinois. Thousands of protesters – mostly Native Americans – have traveled to the Standing Rock reservation over the past few weeks to camp nearby and show solidarity with the tribe’s bid to halt the pipeline.

The standoff over the construction had grown tense in recent days.

After the tribe specified to the court which area it considered to be sacred and historic, Dakota Access workers began to plow under those areas. Tribe members tried to intercede. They were stopped by private security workers, some using guard dogs and pepper spray. The resulting photos showed snarling dogs lunging at protesters; a tribal spokesman said demonstrators were bitten, while the sheriff’s department said private security guards, as well as dogs, were also hurt.

For tribal leaders, the government’s announcement immediately following the court’s ruling against it was a huge victory.

“Our hearts are full; this an historic day for the Standing Rock Sioux Tribe and for tribes across the nation,” said Dave Archambault II, chairman of the Standing Rock Sioux Tribe.