A federal judge on Monday struck down an Idaho law that banned documentation of animal abuse at livestock operations, ruling that it violated freedom of speech and other constitutionally guaranteed rights.

The measure, approved by the Republican-controlled state legislature and signed into law by Governor C.L. “Butch” Otter in 2014, was crafted in response to a video released by animal-rights activists showing workers at an Idaho dairy dragging a cow across the floor by a chain on its neck and repeatedly beating, kicking and otherwise abusing other cows.

But U.S. District Judge Lynn Winmill agreed with the American Civil Liberties Union of Idaho, the Animal Legal Defense Fund and other groups that sued to overturn the statute in finding that the so-called ag gag law violated protections of free speech under the First Amendment to the U.S. Constitution.

“The effect of the statute will be to suppress speech by undercover investigators and whistleblowers concerning topics of great public importance: the safety of the public food supply, the safety of agricultural workers, the treatment and health of farm animals, and the impact of business activities on the environment,” Winmill wrote.

The judge rejected arguments by attorneys for the state and Otter suggesting the statute was designed to protect private property and the privacy of agricultural facility owners and not to suppress free speech critical of livestock operations.Winmill also found that the law violated the constitutional guarantee of equal protection since it was substantially motivated “by animus towards animal welfare groups,” according to the decision.

The judge noted that the Republican state senator who was a sponsor of the measure likened undercover investigations of livestock operations to “terrorism.”

The ACLU of Idaho and others welcomed the ruling as the first step in legally defeating or forcing the repeal of similar ag gag measures enacted in recent years in several U.S. states.

“Everyone benefits today, not just because the court has upheld our constitutional rights, but because this decision will help protect our animals, our workers, and our food,” said ACLU of Idaho Legal Director Richard Eppink.

A spokesman for Otter said the governor was not prepared to immediately comment.