"Audio and visual evidence is a uniquely persuasive means of conveying a message, and it can vindicate an undercover investigator or whistleblower who is otherwise disbelieved or ignored," Winmill wrote in his 29-page ruling. "Prohibiting undercover investigators or whistleblowers from recording an agricultural facility's operations inevitably suppresses a key type of speech because it limits the information that might later be published or broadcast."

A coalition of animal activists, civil rights groups and media organizations sued the state more than a year ago, opposing the so-called "ag-gag" law. The coalition said the law curtailed freedom of speech and made gathering proof of animal abuse a crime with a harsher punishment than the penalty for animal cruelty.

Idaho lawmakers approved the law in 2014 after the state's $2.5 billion dairy industry complained that videos of cows being abused at a southern Idaho dairy filmed in 2012 unfairly hurt their business.

"Idaho's lawmakers should be ashamed of wasting precious time and valuable resources enacting unconstitutional laws that threaten animal welfare, food safety, workers' rights, and the environment," Nathan Runkle, president of Mercy For Animals, the animal rights group that released the 2012 footage, said in a statement.

Many lawmakers argued the law was needed to protect private property owners' rights. However, Winmill countered that there are already state and federal laws on the books that protect private property.

Attorney General Lawrence Wasden's office declined to comment. Spokesman Todd Dvorak said the office was reviewing the ruling.

The ruling is the first in the country to deem an anti-dairy spying law unconstitutional, said Mathew Liebman of the Animal Legal Defense Fund, one of the lead attorneys on the Idaho case.

The only other similar lawsuit is in Utah, but more are likely to come after Monday's decision, he said. Currently, eight other states have passed some sort of law against such surreptitious filming, even though many more have been introduced in state legislatures.

"This decision vindicates the public's rights to know how animals are treated before they become meat," Liebman said.

Idaho lawmakers approved the law in 2014 after the state's $2.5 billion dairy industry complained that videos of cows being abused at a southern Idaho dairy filmed in 2012 unfairly hurt their business.

The Associated Press