Elon Musk and his electric car company were in the wrong when they fired a worker involved with labor organizing at Tesla's Fremont plant, and Musk broke the law with a tweet about the effort, according to an administrative law judge in California.

In a Friday ruling, Judge Amita Baman Tracy ruled that Tesla acted illegally in several ways with regard to a union organizing campaign that took place in 2017. For one, Tesla security guards should not have been questioning workers who were leafletting for the union effort in the plant parking lot or ordering those workers to leave the property. Also, the judge ruled that the company should not have fired a worker who lied under questioning about how he gained access to internal information about a fellow worker who was opposing the union effort.

As Ars Technica reports, the firing occurred in October 2017, and the company terminated one Richard Ortiz. A union-affiliated employee, Jose Moran, had accessed the company's HR system and sent Ortiz a screenshot of information about the anti-union employee. When the company questioned Ortiz about how he accessed the information, he apparently lied, and the company subsequently fired Ortiz and disciplined Moran. The judge ruled that Ortiz should be reinstated at his job with back pay, and wrote, "An employer may not terminate an employee for lying in response to questions regarding [union organizing]."

Further, the judge found that Musk's tweet on May 20, 2018, in which he subtly discouraged employees from voting for the union by suggesting that they would be sacrificing stock options if they joined a union.

Judge Tracy ruled that Musk was illegally trying to sway workers to reject the union by suggesting they would lose a benefit, in this case stock options, if they unionized.

The judge has ruled that, among other remedies, Tesla must post a notice informing workers of their right to organize.

This isn't the first time a tweet has gotten Musk into legal trouble in recent years. An August 2018 tweet in which Musk suggested he could take the company private resulted in a $40 million fine from the SEC and in Musk having to step down as company chairman. Then in February of this year, Musk tweeted something about a vehicle production estimate that the SEC also said was illegal, and Musk was found in contempt of court from the earlier settlement.