A federal judge denied Tesla’s motion to dismiss charges in a lawsuit claiming that it mistreated foreign workers. This means the automaker will have to defend itself at trial against allegations that foreign workers at its Fremont factory worked shifts that violated forced labor laws and were threatened with deportation if they reported injuries.

The ruling comes just a few days after Elon Musk agreed to resign as Tesla’s chairman (while staying on as its CEO) to settle with the U.S. Securities and Exchange Commission. The SEC filed a complaint in federal district court last week charging Musk with fraud related to his tweets in August that he planned to take Tesla private at $420 a share.

In a ruling made on Monday, Judge Lucy Koh of California Northern District Court in San Jose dismissed five out of seven claims in the lawsuit, Lesnik v. Eisenmann SE (case number 5:16-cv-01120), and denied motions to dismiss from Tesla subcontractors Eisenmann Corp and ISM Vuzem.

Other vehicle makers (Mercedes-Benz, Deere, REHAU, LaX, Volkswagen, Dicastal, and BMW) were also named as defendants, but dismissed because they aren’t included in the two claims that will go to trial.

The class action lawsuit was filed in 2016 by Gregor Lesnik, from Slovenia, and Stjepan Papes, from Croatia, on behalf of foreign workers covered by B-1 visas. Both Lesnik and Papes were hired by ISM Vuzem and sent to the U.S. to work at Tesla’s Fremont facility. The suit alleges that foreign workers were paid far below minimum wage and worked “extreme hours.”

Lesnik claims that he typically worked 12 hours a day and never less than 10 hours, over 80 hours a week, adding up to more than 240 hours a month, but only received one day off every two weeks, in violation of forced labor laws.

When Lesnik was too sick to work or reported a job injury, the suit alleges Vuzem threatened to withhold pay or visa and immigration benefits. Koh rejected arguments that Tesla and Eisenmann are not liable for abuses by ISM Vuzem because they benefitted financially.

Tesla’s auto manufacturing plant in Fremont was scrutinized last year after complaints by employee Jose Moran, which were denied by CEO Elon Musk in a staff email. Earlier this year, California’s Division of Occupational Safety and Health said it would look into conditions at the factory after Reveal reported that Tesla did not accurately report work injuries, as required by state and federal law (charges Tesla also denied).

While it’s labor and safety practices were being criticized, other workers also filed several lawsuits alleging racial discrimination and harassment at the Fremont plant.

TechCrunch has contacted Tesla, Eisenmann and ISM Vuzem for comment.