Tesla Model S's and X's charge in an underground parking lot next to a Tesla store in San Diego last month. (Reuters/Mike Blake)

Tesla chief Elon Musk said last week that the company’s layoffs of 9 percent of its workforce wouldn’t affect production as the all-electric automaker races to build thousands of new Model 3 sedans a week.

But documents the company filed days later with the state of California show that more than 400 workers will be terminated at its Fremont factory, including dozens of directors, managers, technicians and other workers in manufacturing, engineering and quality inspection.

The mass layoffs offer a glimpse of the surging pressure the company is facing to keep up with the ambitious goals Musk has set. Factory workers say they’re being pushed to ramp up work even as their co-workers are being pushed out the door.

But they also suggest the space-age car company is facing more chaos at the factory than its drivers and investors may understand. The company has, unconventionally, moved some car production to a giant tent. And Musk, in recent all-employee emails, said the company suffered setbacks from a factory fire and an internal saboteur.

Tesla pledged to make 5,000 of its mass-market Model 3 sedans every week by the end of 2017, but the company has been mired in what Musk called “production hell,” a delay that has hurt investor confidence and constrained the company’s sales.

But as Musk has revved up workers toward that goal, he has also called on them to be “extremely vigilant” in patrolling for “outside forces” bent on sabotaging their work.

In a company-wide email, sent just before midnight on Sunday and provided to The Post, Musk said an unnamed Tesla employee had sabotaged operations and ferreted away “large amounts of highly sensitive Tesla data.”

Though Musk noted the worker’s “stated motivation” was not receiving a promotion, Musk said “there may be considerably more to this situation than meets the eye,” and pointed to a "long list of organizations that want Tesla to die,” including Wall Street investors striving to profit from Tesla’s failure, legacy automakers challenged by a growing rival, and oil-industry moguls seeking to boost gas-guzzling cars.

In another email nine hours later, Musk said there had been “another strange incident that was hard to explain” — a small fire in the factory that stopped production for several hours.

The Fremont Fire and Police departments said they were not called to respond to the factory, and the company declined to provide further comment on the emails. “Only the paranoid survive,” Musk wrote.

The billionaire tech entrepreneur has long advanced a viewpoint of Tesla-against-the-world, helping build his upstart car company’s reputation as a nail in the tire of Big Auto. But Musk’s latest wave of conspiracy thinking — coming within days of similar attacks on labor unions and journalists — has surprised even long-time Tesla watchers.

“He’s always been combative,” said Mike Ramsey, an automotive research director at Gartner, the advisory firm. But “the public displays of paranoia have become increasingly odd. To me, they seem to reflect a level of anxiety or pressure that I haven’t seen recently.”

That pressure has also seeped into the company’s 10,000-employee car factory in Fremont, California. Though Tesla has said it wants it “to be the safest factory on Earth,” three factory workers told The Post that they worried the accelerated Model 3 demands could compromise the cars’ safety and lead to more injuries and worker burnout.

“We’re a NASCAR pit crew,” said one worker, who declined to be named because he feared retaliation. “We’re doing this at the speed of light.”

One worker said he was afraid to raise his concerns with his supervisor amid ongoing Tesla layoffs. The company declined to comment.

California’s Division of Occupational Safety and Health, or Cal/OSHA, has opened two active investigations into Tesla, one of which involves a 30-year-old worker who was taken to the hospital after a piece of factory equipment broke his jaw. Those investigations are ongoing, the agency said Tuesday.

The layoffs, Musk said, were part of a “difficult but necessary” reorganization targeting mostly salaried employees, not workers on the production line, adding that the cuts would “not affect our ability to reach Model 3 production targets in the coming months."

The layoff documents, known as Worker Adjustment and Retraining Notification or WARN notices, name only a fraction of the lost Tesla jobs. More than 80 workers will be laid off at Tesla’s Palo Alto headquarters, the notices say.

To speed up car production, Musk said Tesla is now testing an unconventional alternative, raising a giant tent structure on the Fremont grounds and building a new factory line inside from warehouse scrap.

The “pretty sweet” tent, Musk said on Twitter, is “more comfortable” and “way better” than the factory building, and Musk on Twitter congratulated the team for building an “entire new general assembly line in 3 weeks (with) minimal resources.”

Fremont building permits show the open-air structure is temporarily approved for up to 6 months, and show that fire sprinklers and other building features have been deferred.

Industry experts said it’s incredibly rare for a carmaker to sprint toward production goals by pitching a tent. “I have literally never heard of any major manufacturer of any sort doing this, ever,” Ramsey said.

Saying “humans are underrated,” Musk has in the past blamed excessive automation and other factors for production slowdowns.

“The machines can only do so much,” said Bill Selesky, a Tesla analyst at Argus Research. “Elon finally realized, ‘Wow, you can’t do this without employees.’” But, he said, “they’re the ones who get the job done.”