Across the country, legislatures are responding to whistleblowers and activists who have exposed inhumane and at times unsanitary practices at farms by passing laws that criminalize the taking of photos or videos at agricultural facilities.

Farming interests have publicly backed the campaign to outlaw recording. But emails I obtained through a records request reveal that in Idaho, which passed an “ag-gag” law last year, dairy industry lobbyists actually crafted the legislation that was later introduced by lawmakers.

State Sen. Jim Patrick, R-Twin Falls, said he sponsored the bill in response to an activist-filmed undercover video that showed cows at an Idaho plant being beaten by workers, dragged by the neck with chains, and forced to live in pens covered in feces, which activists said made the cows slip, fall and injure themselves. The facility, Bettencourt Dairies, is a major supplier for Burger King and Kraft. The workers who were filmed were fired.

Introducing the bill, Patrick compared the activists behind the Bettencourt video to marauding invaders who burned crops to starve their enemies. “This is clear back in the sixth century B.C.,” Patrick said, according to Al Jazeera America. “This is the way you combat your enemies.”

Idaho is a major center for dairy production, an industry that generates $2.5 billion a year in the state.

Patrick’s bill was introduced on February 10, 2014, sailed through committee within days, and was signed by Gov. C.L. “Butch” Otter on February 28. The legislation calls for a year in jail and fines up to $5,000 for covertly recording abuses on farms or for those who lie on employment applications about ties to animal rights groups or news organizations.

But the groundwork was laid by Dan Steenson, a registered lobbyist for the Idaho Dairymen’s Association, a trade group for the industry.

Steenson testified in support of the ag-gag bill, clearly disclosing his relationship with the trade group. Emails, however, show that he also helped draft the bill. On January 30, before Sen. Patrick’s bill was formally introduced, Steenson emailed Bob Naerebout, another Dairymen lobbyist, and Brian Kane, the assistant chief deputy of the state attorney general’s office, with a copy of the legislation. “The attached draft incorporates the suggestions you gave us this morning,” Steenson wrote, thanking Kane for his help in reviewing the bill. Kane responded with “one minor addition” to the legislation, which he described to Steenson as “your draft.”

The draft text of the legislation emailed by Steenson closely mirrors the bill signed into law.

“Dan and the Idaho dairymen had a large input but also Idaho Farm Bureau as well as Idaho-eastern seed growers,” Patrick said in an email to The Intercept. “This was not about only dairy so but all of agriculture since all farms have risks of distorted facts,” he added. “We only want the whole truth to be told not just a few social media sites.”

The law made Idaho the seventh state to pass “ag-gag” efforts. Similar efforts have been signed into law in recent years in Utah, Iowa and Missouri.

This week, North Carolina may become the next state to do so. The North Carolina version of the act covers not just farms and agricultural facilities, but many other workplaces, including nursing homes and daycares — an expansion of the law that critics say will muffle whistleblowers. North Carolina Gov. Pat McCrory is deciding whether to sign or veto the legislation.

View the Idaho emails below: