Tesla told employees Tuesday it will cut about 9 percent of its workforce, trimming mostly salaried positions.

Since the start of the year, Tesla has added roughly 8,000 jobs and currently employs approximately 46,000 workers. Through this reorganization, it will shed about 4,100 jobs.

In mid-May, Tesla CEO Elon Musk had warned the company was undertaking a "thorough reorganization" and that it would flatten its management structure.

"To be clear, Tesla will still continue to hire outstanding talent in critical roles as we move forward and there is still a significant need for additional production personnel," Musk said in a letter to employees on Tuesday. "I also want to emphasize that we are making this hard decision now so that we never have to do this again."

Musk echoed this sentiment in a tweet he sent Tuesday, saying the cuts were "difficult, but necessary."

Musk

CFRA analyst Efraim Levy took the news as a sign Tesla is maturing and prioritizing profitability.

"There is a normal ebb and flow of hiring and firing in a business," he said. "Nine percent is a big chunk to do at once, but there comes a time when a company grows up and they have to cut out the fat to become more efficient."

In the email to employees, Musk said "profit is obviously not what motivates us," given the company's nearly complete historical lack of it. But, he said, now Tesla needs to reduce costs and make money.

Ahead of the layoff announcement, Tesla shares had been trading up 5 percent and the stock was on pace to show its best month since February 2014. After the news, the stock gave up some of its gains, but was still on pace for its third-straight day of gains.

While sentiment has been warming, at least as far as the stock is concerned, Tesla has recently shown signs of being a company in turmoil. It has been burning through billions of dollars as it tries to scale up production of its Model 3 sedan, Tesla's lowest-priced vehicle and its first attempt at making a car for the mass market.

It has been criticized for missing production targets, even after these goals were revised. Tesla currently is trying to reach a production rate of 5,000 Model 3 cars in a single week by the end of this month.

Separately, Musk has said he expects Tesla to be profitable and cash flow positive in the third quarter. But some analysts think the company will need to raise more capital by the end of the first quarter of 2019.

The company has also seen quite a bit of turnover in its ranks, and several senior executives have left over the last several months.

Meanwhile, Tesla has defended itself in court on Monday against complaints from the National Labor Relations Board that Tesla was intimidating employees involved in union activities.

Tesla's advanced driver assistance system, Autopilot, has also drawn federal scrutiny, following its involvement in some high-profile crashes.

Also disconcerting, has been Musk's combative attitude toward Wall Street and the press, which rose to a head during its first-quarter earnings conference call.

But in recent days, there has been a growing conviction that Tesla is making progress on Model 3 production. On Monday, KeyBanc Capital Markets analyst Brad Erickson raised his second-quarter Model 3 delivery estimate to 30,000 from 20,000, based on conversations with staff at Tesla stores.

And some analysts think Tesla can achieve gross margins of 25 percent on the Model 3, which Tesla is still targeting. Others have been skeptical the company can pull in profits that high on a vehicle that starts at just $35,000, compared with Tesla's far more expensive Model S and X sedans. Indeed, Tesla has been prioritizing the production of more expensive Model 3 versions.

Tesla has grown rapidly in recent years. Even with the work force reductions announced Tuesday, Tesla will still employ more people now than it did at the end of 2017.

In its email to employees, Tesla noted that there had been some duplication of roles and job functions as it scaled quickly. Those are the areas that will be targeted with cuts.

Tesla said no production associates were impacted by the restructuring.

The company also has decided not to renew its residential sales agreement with Home Depot as it focuses its efforts on selling solar power in Tesla stores and online.

A copy of Musk's email to Tesla employees follows:

As described previously, we are conducting a comprehensive organizational restructuring across our whole company. 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. As part of this effort, and the need to reduce costs and become profitable, we have made the difficult decision to let go of approximately 9% of our colleagues across the company. These cuts were almost entirely made from our salaried population and no production associates were included, so this will not affect our ability to reach Model 3 production targets in the coming months. Given that Tesla has never made an annual profit in the almost 15 years since we have existed, profit is obviously not what motivates us. What drives us is our mission to accelerate the world's transition to sustainable, clean energy, but we will never achieve that mission unless we eventually demonstrate that we can be sustainably profitable. That is a valid and fair criticism of Tesla's history to date. This week, we are informing those whose roles are impacted by this action. We made these decisions by evaluating the criticality of each position, whether certain jobs could be done more efficiently and productively, and by assessing the specific skills and abilities of each individual in the company. As you know, we are also continuing to flatten our management structure to help us communicate better, eliminate bureaucracy and move faster.



In addition to this company-wide restructuring, we've decided not to renew our residential sales agreement with Home Depot in order to focus our efforts on selling solar power in Tesla stores and online. The majority of Tesla employees working at Home Depot will be offered the opportunity to move over to Tesla retail locations.



I would like to thank everyone who is departing Tesla for their hard work over the years. I'm deeply grateful for your many contributions to our mission. It is very difficult to say goodbye. In order to minimize the impact, Tesla is providing significant salary and stock vesting (proportionate to length of service) to those we are letting go. To be clear, Tesla will still continue to hire outstanding talent in critical roles as we move forward and there is still a significant need for additional production personnel. I also want to emphasize that we are making this hard decision now so that we never have to do this again. To those who are departing, thank you for everything you've done for Tesla and we wish you well in your future opportunities. To those remaining, I would like to thank you in advance for the difficult job that remains ahead. We are a small company in one of the toughest and most competitive industries on Earth, where just staying alive, let alone growing, is a form of victory (Tesla and Ford remain the only American car companies who haven't gone bankrupt). Yet, despite our tiny size, Tesla has already played a major role in moving the auto industry towards sustainable electric transport and moving the energy industry towards sustainable power generation and storage. We must continue to drive that forward for the good of the world. Thanks,

Elon

— CNBC's Phil LeBeau contributed to this story.