Cody Carlson had no way of preparing for this moment. He was a Manhattan kid, days removed from working as an analyst for a business-intelligence firm, where he scrutinized corporations and their executives.

Now he was standing in a bleak barn at New York's largest dairy farm.

There was a medieval feel to the place. Cows were wedged head-to-tail in pens carpeted with their own waste. The air was an acrid blend of urine, manure and chemicals. Some animals were left unattended with open sores that leaked puss. Others lay dying in pens, too sick or weak to stand.

"It's incredibly overwhelming," Carlson says. "Your brain can't process seeing this many animals crammed together in one place."

His first job, technically speaking, was to repair the mechanism that pulled manure from the barn.

His real job: covertly filming it all for Mercy for Animals.

As espionage goes, it was easier than infiltrating a Pizza Hut. Experience told the Los Angeles animal-rights group that it could send an undercover operative to a factory-style farm anywhere and it was certain to find abuse.

Carlson had simply been told to find a job in upstate New York. While the work requires punishing labor while surrounded by stench – all for the princely sum of $8 an hour – it isn't like spying on North Korea. Two days later, he was hired by Willet Dairy.

His hidden camera caught employees kicking and shocking animals that wouldn't bend to their will. Supervisor Phil Niles is heard recounting an abuser's greatest hits: how he beat cows with wrenches, smashed their heads with two-by-fours, kicked them when they were too feeble to rise.

"Fucking kicking her, hitting her," he chortles while recalling one incident. "Fucking jumping off the top of the goddamned gate and stomping on her head and shit."

After five weeks of filming, Mercy for Animals took the footage to ABC's World News. Niles was subsequently charged with misdemeanor animal cruelty. His penalty for nineteen years of beating cows in every way imaginable: a $555 fine.

Prosecutors cleared Willet Dairy of any wrongdoing. But the company did take an uppercut to the wallet. After the video went national, Willet was dumped by one of its major buyers, Leprino Foods, the world's largest mozzarella producer.

Carlson didn't wait around for the fallout. He soon re-emerged at Country View Family Farms in Fannettsburg, Pennsylvania, where nearly 3,000 pigs live as pork-products-in-waiting for Hatfield Quality Meats. Once again, his camera caught the gruesomeness of the factory food chain.

Workers threw piglets by their ears, ripped out their testicles with bare hands sans anesthesia. Constantly impregnated sows were kept in cages just two feet wide, unable to turn around and allowed to walk just four days a year.

"It's about the most sensory-deprived life you can possibly imagine," says Carlson. "Pigs are incredibly smart animals. They're said to be smarter than dogs. Pigs go so insane from these conditions that they bang their heads back and forth against the cage. It looks like a scene from The Matrix."

But like most states, Pennsylvania provides farmers with sweeping exemptions from cruelty statutes. These laws are simple: If it's commonly practiced in agriculture, it can't be construed as abuse.

Country View veterinarian Jessica Clark admits that the video showed violations of the farm's own standards, but says those issues were corrected before Mercy posted the film to the Internet. Because Pennsylvania grants farmers a wide berth in dealing with livestock, no charges were filed.

Carlson soon took a new job working undercover for the Humane Society of the United States. This time he resurfaced in Iowa at Rose Acre Farms, the nation's second-largest egg producer, with nearly five million chickens.

His video showed hens packed into cages the size of a filing drawer, where each creature spent life in a space whose floor had the dimensions of a single sheet of paper.

Carlson's job was to cull the dead, the 100 or so hens whose wings and feet became caught in the caging, leaving them to die of thirst or be trampled to death by their cellmates each day.

"One of my colleagues called it 'pulling carpets,' because they stuck to the bottom of the cage," he says. "I actually had a worker tell me he had nightmares from tearing mummified birds off the cage."

Rose Acre was doing nothing illegal. But to the Humane Society, that was the point. The video depicted something akin to an aviary concentration camp. And not a single government agency showed the slightest concern.

Since the Internet first granted activists a direct pipeline to the public, groups like the Humane Society, Mercy and PETA have waged guerrilla war via undercover video. Each time they've uploaded footage, Big Ag has struggled to explain away what Americans could see with their own eyes.

Today, the guerrillas are winning.

It doesn't seem to matter where the operatives have landed. Be it a slaughterhouse in Vermont or a pig farm in Wyoming, the videos portray factory farms to be "like something from Dante," Carlson says. According to one Kansas State University study, media attention to the welfare of livestock has reduced demand for poultry and pork.

Last year, Big Ag decided to fight back. But not by playing a kinder, gentler game in search of better publicity. Instead, it sought to make criminals of the people exposing its underbelly.

By 2012, Iowa was taking a beatdown.

Its massive egg farms were the subject of online exposés. Its hog factories were being portrayed as porcine versions of puppy mills, where sows are housed in two-by-seven-foot "gestation crates," their lone options in life being to stand up, lie down or give birth.

Costco no longer bought from farms using the crates. Companies like McDonald's, Kroger and Safeway were all in the process of booting them from their supply chains.

For the state's agricultural interests, it was a public-relations nightmare.

Worse, America's appetite was also shifting. Vegetarianism and veganism were on the ascent. The foodie movement had turned to artisanal meat, mostly local and raised by more altruistic hands.

Factory farms still produce more than 90 percent of the country's food supply, but Big Ag could do little to stop the young, urban, educated and moneyed from buying elsewhere. And then there were the videos constantly playing on YouTube, illuminating its sins.

So Iowa decided to outlaw the likes of Cody Carlson.

Last year, the state made it illegal to lie on a job application regarding association with an animal-rights group. It also banned the filming of farms without an owner's consent.

The law was backed by Iowa's largest ag forces, including Monsanto, DuPont and Iowa Select, the state's largest hog producer, which had been stung by an undercover Mercy video the year before.

The bill flew through the legislature in a matter of hours, effectively making exposing cruelty a greater crime than abuse itself. Those found guilty faced up to a year in jail, with felony charges for repeat offenses.

Mary Beth Sweetland heads the Humane Society's investigative unit. She won't speak to the nature of her operation or its people or methods for fear of tipping her hand. But Sweetland readily admits she no longer targets Iowa.

After Iowa passed its law, Missouri and Utah followed, joining Kansas, Montana and North Dakota, which had passed similar statutes two decades earlier, when a more violent strain of activists threatened arson at animal testing labs. Other "ag-gag" bills have since appeared on dockets in ten states, from California to Florida.

The bills tend to be variations of the Iowa law, combo platters of video bans and the criminalization of job-application lies. Most also mandate that anyone with evidence of abuse hand over the footage to police immediately – usually within a day or two.

Those favoring the bills say the stringent reporting requirements will bring a swifter halt to cruelty. They compare them to laws forcing doctors to report the first signs of child abuse.

"We would see the videotape, and the inevitable question is, 'Why didn't you go to the farm owner or the plant manager?'" asks Dale Moore, former chief of staff of the Department of Agriculture under George W. Bush. "Typically they did, but only after they did their fundraising or sensationalizing."

Yet activists see such rhetoric as painfully disingenuous. If Big Ag truly wishes to fight abuse, they argue, it would expand penalties for animal mistreatment, not for those who uncover it.

"I think any rational person can see how absurd it is to criminalize people who expose illegal behavior," says "Jane," a Mercy investigator who wishes to remain anonymous.

The not-so-hidden hand behind the new laws is the American Legislative Exchange Council, better known as ALEC. It's a conservative, pro-business think tank backed by some of the country's largest corporations, including ExxonMobil, Pfizer and Koch Industries.

ALEC was a catalyst behind the "Stand Your Ground" shooting laws and various voter-suppression methods used in the last election. Its specialty is the "model bill," essentially pre-written legislation that allows conservative officials around the country to copy and paste to their desire.

Want to sabotage some environmental laws? ALEC has a menu to choose from.

Want to stop neighbors from suing corporate farms over issues of odor and waste? ALEC can help you do it by this afternoon.

A decade ago, the group began peddling "The Animal and Ecological Terrorism Act," which contained rhetoric so overwrought that it bordered on parody. It sought to make filming a farm an act akin to bombing the Boston Marathon. The guilty would be placed on a "terrorist registry."

Recent rhetoric from ag-gag supporters has been equally over the top.

Take Tennessee state representative Andy Holt, whose own farm produces pork, beef and goat meat. Two years ago, the Humane Society caught Tennessee horse trainer Jackie McConnell slathering caustic chemicals on the ankles of his animals. The pain causes the horses to lift their legs higher during competitions. Footage also showed workers whipping and shocking horses and beating them on the head with sticks.

The Tennessee legislature's response: Crack down on the people who would expose such a thing.

When the state's ag-gag bill passed last month, Holt wrote a letter to the Humane Society that was so blistering – and incoherent – that readers could practically see the spittle as he typed:

"I am extremely pleased that we were able to pass HB 1191 today to help protect livestock in Tennessee from suffering months of needless investigation [by] propagandist groups of radical animal activists, like your fraudulent and reprehensibly disgusting organization of maligned animal-abuse profiteering corporatists, who are intent on using animals the same way human traffickers use seventeen-year-old women," he wrote.

And that was just the opening sentence.

Yet Holt is trumped by Tim Sappington, a former maintenance contractor with Valley Meat in Roswell, New Mexico, which hopes to become the first U.S. slaughterhouse in years to produce horse meat for consumption in Eastern Europe and Asia.

Sappington uploaded a video to YouTube – since removed – showing him petting a horse. "To all you animal activists," he announced to the camera, "fuck you." He then shot the horse point-blank in the head.

Since Sappington would use the horse for meat, it was perfectly legal. Valley Meat fired him anyway.

Last year, as undercover videos pushed Big Ag to desperation, the industry began to temper its language. Iowa's law is essentially a sanitized version of ALEC's bill, cleansed of hysteria and any mention of terrorist registries.

But despite the more diplomatic approach, farmers have been unable to legislate away the images caught on tape. While Big Ag may have politicians on speed-dial, competing in the egalitarian frontier of the Internet isn't its strong suit.

For activists, the turning point in the fight seemed to arrive in 2007, after a Humane Society investigation of the Hallmark Meat Packing Company.

The Chino, California, slaughterhouse was a major supplier to the nation's school-lunch program, delivering beef to 36 states.

But the Humane Society's video showed "downer" cows – those too frail or diseased to walk – being pushed by forklift to slaughter. The practice is highly illegal, since sick animals heighten the risk of introducing E. coli, salmonella and mad cow disease into the food supply.

When it came to light, the USDA issued the largest beef recall in the agency's history. Hallmark went bankrupt.

After Chino, the videos kept coming, each showing conditions that seemed more 1913 than 2013. As one veterinarian puts it, "Ninety-nine percent of the people don't know where their food comes from." And what they saw made them queasy.

Mercy alone has produced twenty investigations in just the past few years.

It isn't especially difficult – at least the infiltration part. Undercover workers are merely directed to apply at large farms. Because the labor is hard and the wages poor – usually under $10 an hour – high turnover plays to an activist's advantage. It's not uncommon to land a job within a day or two. "They use their real names and their real Social Security numbers," says Matt Rice, head of Mercy's investigative team.

He's never had an undercover worker caught. Neither has Sweetland of the Humane Society.

Groups like the Animal Agriculture Alliance, the country's largest coalition of farmers and ranchers, occasionally try to run counter-espionage.

"Jane" says she once caught a spy at an animal-rights conference with a hidden camera in his food. Rice knows of similar attempts, but he dismisses them with a laugh. Video of his group's conferences is readily available to anyone with Internet access.

Over time, the agriculture lobby has appeared increasingly impotent. Even smaller family farms – once the very definition of wholesome Americana – have shown up on film as incubators of depravity.

Ask "Pete," a Texan who's been undercover for eleven years and had his work featured in two HBO specials.

"I know that it sounds kind of unbelievable, that every place out there is breaking the law," he says. "I always tell people that I challenge anyone to try to prove me wrong. Get hired at a slaughterhouse or a farm and go work there. I absolutely promise you you'll find exactly what we find on our investigations."

One of his favorite jobs – if you can call it that – was going undercover at Conklin Farms in 2010. The small dairy in Plain City, Ohio, had just three employees. But its workers compensated for size with sadism.

Pete's video opens with a worker repeatedly stomping on a cow's head. It goes on to show employees stabbing animals in the face with pitchforks, beating their heads with crowbars, punching cows in their udders and body-slamming calves to the ground.

One worker is caught on tape exuberantly describing how they "beat the fuck out of this cow. We stabbed her.... I beat that fucker till her face was this big around."

In a rare case of tough justice, employee Billy Joe Gregg was sentenced to eight months in jail after pleading guilty to animal cruelty.

But as Pete notes, Gregg might still be torturing cows if not for Mercy's undercover work. There isn't a single federal law governing the welfare of farm animals, he says. "There's no investigative body in the country that does that, so it falls on civilians to do it."

But if Big Ag has its way, those civilians will soon be criminals.

"It's a huge embarrassment to have investigation after investigation where your employees are beating animals, kicking them and throwing them," says Sweetland. "I think they're sick of having to make excuses for themselves. One way to stop it is to make it illegal to do these undercover investigations. They refuse to fix the problem, which is this inherently cruel system."

New Mexico state senator Cliff Pirtle is wary of the reporter on the phone. The Republican dairyman can trace his family's farming roots in this country back to the 1700s. He can't comprehend how people like him – once viewed as the salt of the earth – are now being framed as agents of misery.

In February, Pirtle introduced a bill that would outlaw undercover videos in his state. But a strange thing happened between last year's legislative successes and what was supposed to be 2013's triumphant tidal wave.

The ag-gag movement began to self-destruct.

Measures attempting to criminalize activists' activities in states from New Hampshire to Minnesota, Pennsylvania to Indiana, have either stalled or died.

While Big Ag has attacked, activists have gathered allies.

After Tennessee's law passed the legislature, country singer Carrie Underwood tweeted: "Shame on TN lawmakers for passing the ag gag bill. If Gov. [Bill] Haslam signs this, he needs to expect me at his front door. Who's with me?" (Haslam vetoed the bill last week.)

In New Mexico, Pirtle tried to sell his measure under the mantra of property rights. But it's hard to convince consumers that they're best served by less information. His proposal sunk.

The bills have faced resistance on multiple fronts. The American Civil Liberties Union argues that they violate the First Amendment's promise of freedom of speech. Unions like the United Farm Workers claim the laws could cloak unsafe working conditions. The Consumer Federation of America worries they might be used to cover up safety problems in the nation's food supply.

Making matters worse for the ag lobby, Underwood has been joined by celebrities like Ellen DeGeneres, Katherine Heigl and Emmylou Harris.

Farmers' frustrations are exacerbated by the fact that many of the activists are essentially calling for an end to eating meat. At the close of every Mercy video, for example, the narrator urges viewers to adopt a vegan or vegetarian diet. Why would anyone blame agriculture for fighting back?

"These groups want to put an end to meat consumption in this country," says Emily Meredith of the Animal Agriculture Alliance. "The goal of the videos is to repulse the meat-eating public."

Adds Lou Nave of Tennessee's Farm Animal Care Coalition: "The animal-rights organizations don't think we should use animals in any way."

As Pirtle sees it, America is no longer on speaking terms with its chief source of nourishment.

"I think 100 years ago, the majority of people were one or two generations off the farm," he says. "They would understand the great sacrifice animals make for us to survive. Very few people understand what it takes to get food from the farm to the table. We understand the sacrifice they make to sustain life."

Take those tight gestation crates used for sows. They're designed not to make pigs crazy, but to keep mothers from accidentally suffocating their children, says Tony Bolen, a Wisconsin veterinarian. "The mothers lay on a lot of piglets if they don't have them," he explains.

Moreover, there's little science to suggest that cows seek room to roam. "Cows aren't that social, where they want to go and explore," says Bolen. "The average cow will lay down eight-plus hours a day. They just eat and lay down."

What the public doesn't understand, he says, is that only stupid farmers abuse their animals. The unhappy or unhealthy produce less milk, lay fewer eggs and have fewer babies.

"Most of the farmers, they're treating them right," adds Bolen. "And the animals are pretty much happy, or the farmers aren't making money."

The problem for agriculture: Those "most" seem to rarely show up on film.

In 2011, "Jane" went undercover at a Butterball turkey farm in Shannon, North Carolina. By this point, catching abuse on film was almost routine.

Her hidden camera showed workers stomping birds and bashing their heads with pipes. "We don't need to torture our food before we eat it," she says.

Mercy offered the tape to police. The cops responded by raiding the place with arrest warrants.

They would end up with five convictions. The case also showed why activists are leery of handing over footage before their investigations are complete.

Among the convicted was Dr. Sarah Jean Mason, director of North Carolina's Animal Health Programs, who had seen the tape after police went to the state seeking advice about how to proceed. Mason pleaded guilty to leaking word of the impending raid to Butterball a week before it took place.

"Pete" encountered the same sort of governmental duplicity while undercover at a Vermont veal slaughterhouse. Workers kicked and prodded downed calves with electric probes, pouring water on them to heighten their pain.

Also featured on the tape: A USDA inspector warning Pete not to tell him about the most egregious violations, since it would force him to shutter the plant.

Both cases reflect the reluctance of some authorities to fight animal abuse. Meanwhile, Big Ag still hopes to criminalize the few people willing to expose it.

This past February, it bagged its first catch.

Twenty-five-year-old Amy Meyer was standing on a public road in Draper City, Utah, watching the cows at the Dale Smith & Sons Meat Packing Company.

As she would later tell independent journalist Will Potter, she noticed "a live cow who appeared to be sick or injured being carried away from the building in a tractor as though she were nothing more than rubble."

Meyer took out her cell phone and started recording. A Smith manager called the police, claiming Meyer had trespassed. But a Draper City officer allowed her to leave, believing she had remained on public land.

Two weeks later, city prosecutor Ben Rasmussen charged Meyer with "agricultural operation interference," a crime under Utah's new ag-gag law. She became the first person in American history to be ensnared for the crime of filming cows.

In April, Potter posted the tale of Meyer's travails on his website, Green Is the New Red (greenisthenewred.com). The story went viral, attracting hundreds of thousands of readers before the site crashed from the volume.

Within a day, Rasmussen decided Meyer didn't make a very good criminal after all and dropped the charges.