(Reuters) - The Trump administration unlawfully withdrew a plan to limit the number of whales, turtles and other marine creatures permitted to be inadvertently killed or harmed by drift gillnets used to catch swordfish off California, a federal judge has ruled.

The decision requires U.S. fisheries managers to take steps to implement the plan, which calls for placing numerical limits on the “bycatch” of bottlenose dolphins, four whale species and four sea turtle species snared in swordfish gillnets.

As currently written, the regulation in question also would mandate suspension of swordfish gillnet operations altogether off Southern California if any one of the bycatch limits were exceeded.

The Pacific Fishery Management Council endorsed the plan in 2015, and it was formally proposed for implementation by the U.S. Commerce Department’s National Marine Fisheries Service the following year.

The rule was expected to gain final approval but was abruptly withdrawn instead in June 2017 under President Donald Trump, whose Commerce Department determined the cost to the commercial fishing industry outweighed conservation benefits.

The environmental group Oceana sued, accusing the Commerce Department of violating U.S. fisheries laws and the federal Administrative Procedures Act. Oceana also asked the courts to order the agency to put the bycatch limits into effect.

U.S. District Judge R. Gary Klausner declined to force the National Marine Fisheries Service to immediately implement the restrictions in a decision handed down Wednesday in Los Angeles.

But he sided with environmentalists in finding the agency’s reversal exceeded its authority and was “arbitrary, capricious or an abuse of its discretion.”

Klausner ordered federal fisheries managers to either re-issue the regulations as written or consult with the Pacific Fishery Management Council on any revisions.

Drift gillnets, consisting of mile-long (1.8 km-long) strands of nylon mesh draped 200 feet (60 meters) deep in the ocean from surface floats, pose a hazard to a wide assortment of marine mammals and turtles that can become entangled and drown.

According to Oceana, the 20 vessels that make up the California drift gillnet fishery ended up discarding 61 percent of their catch from 2004 to 2017.

The Marine Fisheries Service said Friday it had not yet seen the judge’s ruling and was unable to comment.

Oceana attorney Mariel Combs told Reuters the legal finding marked a victory for marine wildlife.

“The National Marine Fisheries Service’s decision to withdraw those important protections was irresponsible and illegal,” she said.