Wal-Mart Stores Inc. has agreed to pay $40 million to 87,500 Massachusetts employees who claimed the retailer denied them rest and meals breaks, manipulated time cards and refused to pay overtime, according to court documents filed Wednesday.

The settlement — believed to be one of the largest of its kind in the state — seeks to resolve a class action lawsuit filed in 2001. It comes less than three months after the world’s largest retailer reached a deal with state prosecutors to pay $3 million to settle complaints that it didn’t give its Massachusetts workers proper meal breaks.