A federal judge in New York has invalidated rule changes by the Trump administration that allowed individuals and corporations to kill scores of birds as long as they could prove they did not intentionally set out to do so.

In a blistering ruling that cited Harper Lee’s “To Kill a Mockingbird,” U.S. District Judge Valerie E. Caproni ripped the administration’s interpretation of “takings” and “killings” of birds under the century-old Migratory Bird Treaty Act as applying only if the animals are specifically targeted.

Tuesday’s ruling was the latest legal setback for the Trump administration as it has systematically tried to weaken or nullify scores of federal environmental protections. In her decision, Caproni said the administration had gone too far.

“There is nothing in the text of the MBTA that suggests that in order to fall within its prohibition, activity must be directed specifically at birds,” wrote Caproni, who was nominated to the Southern District of New York by President Obama in 2012. “Nor does the statute prohibit only intentionally killing migratory birds. And it certainly does not say that only ‘some’ kills are prohibited.”

The changes made by the Trump administration largely benefited oil companies, which have paid most of the fines for violating the act, according to an analysis by the National Audubon Society.

In the administration’s view, even BP, the company responsible for the 2010 Deepwater Horizon oil spill in the Gulf of Mexico that led to the deaths of an estimated 1 million birds, would not be liable for punishment under the law. A landowner who destroys endangered owl nests without checking before building a barn or an oil company that fails to cover a tar pit that birds could dive into and be killed could not be held responsible as they have for decades.

Caproni determined that allowing the U.S. Fish and Wildlife Service police to enforce the act only if officials could prove intent was a violation of the federal Administrative Procedure Act and vacated the changes. In striking down the rule change, she admonished the Interior Department with a passage from “To Kill a Mockingbird.”

“It is not only a sin to kill a mockingbird, it is also a crime,” Caproni wrote. “That has been the letter of the law for the past century. But if the Department of the Interior has its way, many mockingbirds and other migratory birds that delight people and support ecosystems throughout the country will be killed without legal consequence.”

Eight state attorneys general challenged the administration when it weakened the act two years ago. Led by then-New York Attorney General Barbara Underwood, the coalition included the top attorneys in Maryland, New Jersey, Illinois, Massachusetts, Oregon, California and New Mexico.

The court joined their lawsuit with another challenge filed by the National Audubon Society and numerous other conservation groups, including the Center for Biological Diversity.

“This is a huge victory for birds and it comes at a critical time — science tells us that we’ve lost 3 billion birds in less than a human lifetime and that two-thirds of North American birds are at risk of extinction due to climate change,” Sarah Greenberger, interim chief conservation officer for the National Audubon Society, said in a statement.

Interior Department spokesman Conner Swanson defended the rule change. “Today’s opinion undermines a common sense interpretation of the law and runs contrary to recent efforts, shared across the political spectrum, to decriminalize unintentional conduct,” he wrote in an email.

The Trump administration has suffered numerous defeats in its effort to scuttle long-standing environmental protections, calling them onerous requirements that were harming industry and development.

In February, a federal judge in Idaho voided nearly 1 million acres of oil and gas leases on federal lands in the West, echoing an earlier decision in saying the Trump administration was “arbitrary and capricious” in the way that it limited public input on those leases.

In the weeks leading up to the Migratory Bird Treaty Act rule change in 2018, the administration lost three court cases in three consecutive days. The U.S. Court of Appeals for the District of Columbia Circuit ruled in 2018 that the Environmental Protection Agency’s move to delay new chemical and safety requirements was “arbitrary and capricious.”

A day before, a judge on the U.S. District Court in South Carolina reinstated a rule in 26 states limiting the dredging and filling of streams and waterways on the grounds that the EPA had not solicited sufficient public input. Before that, a judge on the U.S. District Court of Montana ordered the State Department to conduct a more extensive environmental impact statement of the Keystone XL’s proposed route through Nebraska.

The 1918 Migratory Bird Treaty Act was enacted after several species of common birds became extinct. The administration’s action reversed decades of efforts by Republican and Democratic administrations to protect the animals as they navigate the globe. The law covers such disparate birds as eagles, red knots, Canada geese and vultures.

Oil companies were the greatest beneficiaries of the new interpretation, according to an analysis by the Audubon Society. They were responsible for 90 percent of incidental takes prosecuted under the act, resulting in fines of $6,500 per violation. Two disastrous oil spills, the BP Deepwater Horizon spill off Louisiana in 2010 and the Exxon Valdez oil tanker wreck off Alaska in 1989, accounted for 97 percent of the fines, according to the Audubon Society.

In striking down the Interior Department’s rule change, Caproni deferred to how Congress framed the law. “It shall be unlawful to hunt, take, capture, kill, attempt to take, capture or kill … by any means whatever … at any time or in any manner, any migratory bird, included in the terms of the convention between the United States and Great Britain for the protection of migratory birds,” it said.

Caproni granted a motion by the state attorneys and conservationists to vacate the Interior Department’s decision. Attorneys for the Interior Department sought to delay the court’s remedy for undermining the will of Congress when it enacted the Migratory Bird Treaty Act and amended it throughout the years. The judge dismissed that attempt.

“Interior presents no indication that vacating the Opinion will disrupt enforcement or other agency efforts,” she wrote.

“The court’s decision is a ringing victory for conservationists who have fought to sustain the historical interpretation of the Migratory Bird Treaty Act to protect migratory birds from industrial harms,” Jamie Rappaport Clark, the president and chief executive of Defenders of Wildlife, said in a statement.

Clark called the federal action a wrongheaded move that “would have left the fate of more than 1,000 species of birds in the hands of industry.”