Tesla announced Tuesday it plans to lay off as much as 9 percent of its workforce, a move that could eliminate thousands of the electric car maker's roughly 40,000 employees.

In a companywide email, chief executive Elon Musk described the decision as a “restructuring” and said it would affect only white-collar, salaried staffers — not the factory workers building the next fleet of Model 3 cars.

“Tesla has grown and evolved rapidly over the past several years, which has resulted in some duplication of roles and some job functions that, while they made sense in the past, are difficult to justify today,” Musk wrote.

The chief executive said he intends to reduce the number of middle management roles.

“As you know, we are also continuing to flatten our management structure to help us communicate better, eliminate bureaucracy and move faster,” he wrote.

The changes come as the company attempts to cut costs and for the first time return an annual profit.

Last week, Musk overcame an attempt to strip him of his role as chairman of Tesla's board, a plan introduced by a company shareholder who raised doubts about Musk's ability to manage multiple companies simultaneously.

Afterward, an emotional Musk tried to signal brighter days ahead for the Tesla, predicting that the company would reach its twice-delayed goal of pushing out 5,000 Model 3s a week by the end of June.

He also predicted that Tesla would start making money in the third and fourth quarters.

“One of the biggest mistakes we made was trying to automate things that are super easy for a person to do, but super hard for a robot to do,” he said.

In October, Tesla fired "hundreds of workers" following annual performance reviews. The company said the firings involved non-manufacturing positions and were unrelated to production delays involving the Model 3.

The San Jose Mercury News, which first reported the dismissals, said the departures included “engineers, managers and factory workers.” Employees told the newspaper that they received “little or no warnings” before the firings, which reportedly targeted 400 to 700 workers, leading to “lowered morale through many departments.”

Tesla has struggled in recent months to resolve nagging production issues surrounding the Model 3 rollout.

Despite glowing reviews and a cult-like following of eager buyers, new Model 3s have trickled out of Tesla's factories months behind schedule.

Tuesday's announcement of job cuts was a sign that Tesla is under increasing pressure to show a profit, said Michelle Krebs, executive analyst for the online car marketplace Autotrader.

“Tesla has signaled organizational changes in recent weeks and here it is," Krebs said. "It is clear that Tesla is under tremendous pressure to finally turn a profit and is attempting to address it by cutting overhead. Also notable is Tesla is not cutting production jobs at a time when pushing Model 3s out the door is a top priority.”

Rebecca Lindland, executive analyst at Kelley Blue Book, said Tesla is scrambling to accommodate demand for its electric cars.

The company recently invested heavily in automation, a move that proved pricier and at times slower than human labor. There’s now a backlog of approximately 425,000 orders.

“They continue to go through cash without getting revenue in,” Lindland said, “and that is unsustainable.”

Jobs related to the Model 3 mission, including those in research and design, are likely safe, she said: “This is a way to trim down some of the excess in other departments.”

Critics have panned Musk for being unpredictable, a label likely exacerbated by the chief executive's history of making unrealistic projections about Tesla timelines and deliveries.

“I think I do have, like, an issue with time,” Musk said minutes after shareholders voted to maintain his status as Tesla’s chairman at the company’s annual shareholders meeting last week. “I’m a naturally optimistic person. I wouldn’t have done cars or rockets if I wasn’t. I’m trying to recalibrate as much as possible.”

And yet Musk's dreamy projections — laced with a confidence that excites fans and opens investor's pocketbooks — have fueled Tesla's success since the company's inception, analysts say.

Until this year, the company's expensive electric cars have catered to early adopters: people with enough income and patience to tolerate what Silicon Valley insiders have dubbed "Elon time."

But Tesla is no longer a startup, analysts say, and the Model 3 was designed to appeal to the mass market, a group of car buyers that will expect the kind of predictability that they associate with the GMs and Fords of the world.

Tesla has also pushed back against accusations of poor worker safety practices and discrimination at company facilities, as well as headline-grabbing wrecks and investigations that have raised questions about the company’s semi-autonomous driving technology.