WASHINGTON — The Supreme Court on Tuesday sided with thousands of workers at an Iowa pork processing plant who had sought to band together in a single lawsuit to recover overtime pay from Tyson Foods.

Justice Anthony M. Kennedy, writing for the majority in the 6-to-2 decision, said the plaintiffs were entitled to rely on statistics to prove their case. The ruling limited the sweep of the court’s 2011 decision in Walmart Stores v. Dukes, which threw out an enormous employment discrimination class-action suit and made it harder for workers, investors and consumers to join together to pursue their claims.

The Tyson workers performed tasks that were “grueling and dangerous” at a plant in Storm Lake, Iowa, Justice Kennedy wrote, slaughtering hogs, trimming the meat and preparing it for shipment. They sought to be paid for the time they had spent putting on and taking off protective gear to prevent knife cuts.

Tyson did not keep records, and the workers tried to prove their damages based on an expert witness’s statistical inferences from hundreds of videotaped observations of how long it took the workers to get ready.