A state judge in Minnesota has ruled that Wal-Mart Stores violated state laws on rest breaks and other wage matters more than two million times and as a result could face more than $2 billion in fines. The judge has threatened to impose a $1,000 penalty for each violation.

The judge also ruled on Monday that Wal-Mart owed $6.5 million to 56,000 current and former employees because of contractual violations, including a failure to give workers promised rest breaks at least 1.5 million times. The judge also found that Wal-Mart managers in Minnesota had systematically broken the law by having employees take in-house training while off the clock.

“It’s been a long time coming,” said William R. Sieben, a lawyer for the plaintiffs, who filed the lawsuit nearly seven years ago. “It’s only through a decision like this that Wal-Mart can be held to its contractual agreements and to complying with Minnesota law.”

The judge, Robert R. King Jr. of the First Judicial District in Dakota County, ruled in favor of Wal-Mart on several important issues in the class-action lawsuit, finding that Wal-Mart managers did not routinely make cashiers and stock personnel work off the clock while doing their regular jobs.