KAREN BLEIER/AFP via Getty Images “We have a responsibility to speak for the bears, who cannot speak for themselves,” a tribal leader said after the ruling.

A federal judge on Monday restored endangered species protection to about 700 grizzly bears living in or around Yellowstone National Park just days before Wyoming and Idaho were set to allow the hunting of nearly two dozen of the animals.

U.S. District Judge Dana Christensen voided a 2017 decision by the Fish and Wildlife Service to delist the grizzlies, which had been protected under the Endangered Species Act since 1975. He said his order was “not about the ethics of hunting,” but he sided with environmental and tribal groups who argued FWS had failed to consider how removing protections from Yellowstone’s grizzlies would affect the recovery of bears living in other parts of the country.

“By delisting the Greater Yellowstone grizzly without analyzing how delisting would affect the remaining members of the lower-48 grizzly designation, the Service failed to consider how reduced protections in the Greater Yellowstone Ecosystem would impact the other grizzly populations,” Christensen wrote. “Thus, the Service ‘entirely failed to consider an important aspect of the problem.’”

The grizzly population in and around Yellowstone has recovered significantly since it was first listed as endangered more than 40 years ago, and Interior Secretary Ryan Zinke had hailed their recovery when the agency said it planned to remove such protections. But the decision ― first proposed under the Obama administration ― has been widely contentious.

Environmentalists had argued that the growing Yellowstone population was expanding and could soon migrate far enough to merge with other grizzly populations around the U.S. Such an event could help maintain genetic diversity and ensure the long-term survival of the species as it recolonizes areas long devoid of the bears, but it also brought new fears of increased conflicts with humans.

“The Service appropriately recognized that the population’s genetic health is a significant factor demanding consideration,” Christensen wrote in his 48-page decision. “However, it misread the scientific studies it relied upon, failing to recognize that all evidence suggests that the long-term viability of the Greater Yellowstone grizzly is far less certain absent new genetic material.”

Tribal groups, which had sued the federal government over the delisting, hailed the news and urged Zinke to sit down with Native American leaders to discuss future efforts to protect the species as populations grow beyond Yellowstone’s borders.

“We have a responsibility to speak for the bears, who cannot speak for themselves,” Lawrence Killsback, president of the Northern Cheyenne Nation, said in a statement Monday. “Today we celebrate this victory and will continue to advocate on behalf of the Yellowstone grizzly bears until the population is recovered, including within the Tribe’s ancestral homeland in Montana and other states.”

Idaho and Wyoming planned to let hunters kill up to 23 of the animals this fall, the first chance to do so in decades.

“We’re glad the court sided with science instead of states bent on reducing the Yellowstone grizzly population and subjecting these beloved bears to a trophy hunt,” Bonnie Rice, a senior representative of the Sierra Club, said in a statement. “Changing food sources, isolation, inadequate state management plans and other threats that grizzly bears continue to face warrant strong protections until they reach full recovery.”

In a statement to The Washington Post, FWS said it was reviewing the decision.