Tesla and its CEO, Elon Musk, violated federal labor laws when it tried to hamper union organizing at its Fremont factory, a federal administrative law judge in California ruled on Friday.

Among other things, Tesla security guards repeatedly ordered union organizers to stop leafletting in Tesla's parking lots and fired one union organizer for allegedly lying during a company investigation. Elon Musk was also dinged for a tweet that suggested employees would no longer receive stock options if they voted to form a union.

For years, Tesla employees affiliated with the United Auto Workers have been trying to convince their fellow Tesla workers to form a union. UAW members in Tesla's workforce have worn union T-shirts, hats, and pins to work. They have also handed out flyers promoting the union in the parking lots around Tesla's Fremont factory.

Federal labor law shields workers from pressure by employers as they engage in this kind of activity. Employees have a right to solicit union membership on company property during their off hours, and the company isn't allowed to retaliate against employees who exercise these rights. Employers also aren't allowed to offer employees benefits, or threaten them with harms, either individually or collectively, to influence their organizing decision.

But union members say Tesla blatantly violated these laws—and on Friday, Amita Baman Tracy, an administrative law judge in California, agreed.

Tesla violated the law several times, judge rules

On two days in early 2017, union members handed out leaflets in Tesla's parking lot. Tesla security guards repeatedly came out to the parking lot and questioned the workers. They verified that the workers were Tesla employees, then ordered them to leave the property anyway.

The workers stood their ground, pointing out that they had a legal right to be there and refusing to leave. The guards never actually escorted them off the property. But the workers argued that the guards' repeated harassment violated federal labor law. On Friday, the judge agreed.

In another incident, a union-affiliated worker, Jose Moran, accessed Workday, Tesla's internal HR system, to look up information about an employee who opposed the union. Moran took a screenshot of the other worker's Workday page—which included his name, photo, job title, and other information—and texted it to another union-affiliated employee, Richard Ortiz. Ortiz wound up using the anti-union employee's picture in a post on a private Facebook group for pro-union Tesla employees.

Tesla learned about the Facebook post and began investigating. It grilled Ortiz about how he had gotten the information, and Ortiz said he wasn't sure who sent it to him. Tesla then looked at access logs and figured out that Moran had taken the screenshots. It fired Ortiz for allegedly lying about who had sent the image and gave Moran a warning for misuse of Workday.

The judge ruled that Ortiz's firing was illegal. "An employer may not terminate an employee for lying in response to questions regarding" union organizing, the judge wrote. The judge also noted that Tesla did not seem to have standing rules against browsing employees' profiles on Workday or screenshotting them, suggesting that Moran was singled out based on his pro-union efforts. The judge ordered that Ortiz be re-instated with back pay and that the disciplinary action against Moran be scrubbed from his record.

In another incident considered by the judge, Elon Musk tweeted about the union organizing drive.

"Nothing stopping Tesla team at our car plant from voting union," Musk wrote. "Could do so tmrw if they wanted. But why pay union dues & give up stock options for nothing?"

The judge concluded that this, too, was a violation of labor law, since Musk is essentially threatening to stop offering employees stock options if they vote to join a union. That, the judge ruled, was an illegal attempt to sway workers toward an anti-union stance.

Among the remedies ordered by the judge, Tesla is required to post a notice informing workers of their rights—including the right to promote the union on company property. Musk will be required to be in the room as management reads the notice out loud to employees at Tesla's Fremont factory.

The case isn't over. We can expect Tesla to appeal the ruling to the National Labor Relations Board based in Washington.

Tesla has not responded to a Friday email seeking comment about the case.