For indispensable reporting on the coronavirus crisis, the election, and more, subscribe to the Mother Jones Daily newsletter.

In May 2016, a crab fisherman and his son spotted a humpback whale caught in crab fishing lines off the coast of Monterey, California. They called the authorities, and seven hours later the whale was freed. This whale survived, but it was lucky: It was one of at least 71 whales, 54 of which were humpbacks, reportedly entangled in fishing gear off the Pacific Coast in 2016—the highest in recorded history, according to the National Oceanic and Atmospheric Administration.

The current predicament facing humpback whales is something of a reversal of fortunes (or, technically, a reversal of a reversal of fortunes). Humpback whales were once protected as an endangered species under the 1973 Endangered Species Act, but they had largely rebounded by September 2016—specifically, nine separate populations were de-listed because they had recovered—thanks primarily to a 1982 whale hunting ban. Five populations, though, remained threatened or endangered, which legally afforded them new protections as of 2016. The problem is that didn’t happen, and the situation has only gotten more dire for these groups of whales, due to fishing, boating, pollution, and other factors. In one population that migrates to the waters off the coast of California, Oregon, and Washington in spring and summer, for example, only 411 individuals remain. In other areas, healthy humpback populations can reach more than 20,000 individuals.

Now, finally some good news: The Trump administration, which had previously sat on its hands while the whales continued to decline, will have to do something about it.

After the National Marine Fisheries Service identified the five still-vulnerable humpback populations back in 2016, the government was required to designate, within about one year, which parts of the ocean could be classified “critical habitat” for the whale populations. But rather than nail down a conservation plan for the whales, the Trump administration instead proposed a plan to allow oil drilling in oceans bordering the United States and in areas where the humpbacks lived.

So in March 2018, environmental groups Turtle Island Restoration Network, Center for Biological Diversity, and Wishtoyo Foundation sued the Trump administration for violating its “mandatory duty” to designate critical habitat and depriving the whales of “vitally important protections.” On Friday, the Trump administration reached a settlement with those environmental groups and agreed to designate critical habitat in the Pacific Ocean for the whales by the summer of 2019, and finalize those boundaries within the following year. A critical habitat designation basically ensures no federally-permitted activities, like oil drilling, will harm the whale’s habitat, including whale migration routes.

The Trump administration did not immediately respond to a request for comment from Mother Jones.

Environmentalists celebrated the agreement late last week. “Today’s victory means Pacific humpback whales will be safer in their ocean home,” said Catherine Kilduff, a Center for Biological Diversity attorney, in a statement Friday. “This agreement ensures the whales will finally get the protections they need.”

But it’s just one win for animal advocates. The Trump administration has come under repeated fire for failing to protect various marine animals under the Endangered Species Act, including the North Atlantic right whale, which saw a record number of deaths in 2017, and the vaquita porpoise, which has as few as 15 individuals remaining in the wild.

“Once again, when we challenged the Trump administration’s attempt to illegally ignore environmental law in court, the Trump administration has been forced to change course,” said Todd Steiner, executive director of Turtle Island Restoration Network, in a press release Friday. “We will continue to watchdog the process to ensure humpback whales are protected and have a fighting chance at survival and recovery.”