SAN FRANCISCO — About two weeks ago, as stock markets plunged, Tesla CEO Elon Musk tweeted: “The coronavirus panic is dumb.”

That attitude appeared to stretch into this week. Despite a Bay Area-wide shelter-in-place order, he and other Tesla workers continued to work at the company’s factory in Fremont, part of Alameda County.

The move placed Musk in an unusual standoff with local officials, who said the factory does not qualify as “essential business,” the exemption for the roughly 7 million residents who are otherwise supposed to remain in place. Violation of the order carries a potential misdemeanor charge.

“They are not essential during the health crisis,” said Sgt. Ray Kelly, spokesman for the Alameda County Sheriff’s Office, which is handling coronavirus-related inquiries for the county. “It’s not an issue that we are going to take lightly considering the fact that it’s a big employer in the state and the county with 10,000 employees that come in every day to work in the factory.”

Later Wednesday, Kelly said that Tesla had committed to reducing its workforce from 10,000 to 2,500 employees amid the order.

One factory worker, who declined to be named citing a fear of retaliation, said the parking lot was full Thursday morning. Workers were being given masks and having their temperature—but it was otherwise business as usual as the company continued to build cars. The workforce is only slowly dwindling as some workers stay home as the order continues, the worker added.

Silicon Valley has been at the heart of the U.S. novel coronavirus outbreak, with some of the first reported cases of community spread. In response, six Bay Area counties issued a joint order taking effect Tuesday to limit the spread of the disease, telling everyone to stay home except for grocery shopping or other necessities.

Other tech giants including Apple, Google and Facebook headquartered in the counties affected by the order said they were sending workers home last week even before residents were ordered to shelter in place. Musk appeared to be the only tech CEO to resist drastic changes.

Late Monday, Musk sent an email to staff saying he would be at work Tuesday.

“First, I’d like to be super clear that if you feel the slightest bit ill or even uncomfortable, please don’t feel obligated to come to work,” he wrote in an email to staff late Monday, according to the website Electrek, which obtained the memo shortly after it was sent. “I will personally be at work, but that is just me. Totally OK if you want to stay home for any reason.”

Fremont police spokeswoman Geneva Bosques said county attorneys are discussing the language in the order and whether Tesla is among the companies that qualifies for an exemption, but enforcement was not under discussion. Tesla did not immediately respond to a request for comment Wednesday.

Last week, Musk tweeted, “Fear is the mind-killer.“

And late Wednesday, as he continued to question what he called a “panic," he appeared to offer his company’s resources. “We will make ventilators if there is a shortage", he said, in response to a tweet pleading for him to take the matter seriously.

“Which hospitals have these shortages you speak of right now?” he then asked.

(Researchers have said the pandemic could leave cities thousands of ventilators short as patients pour into hospitals.)

Tesla has been ramping up production to deliver its Model Y crossover SUV this month, its biggest launch since the Model 3 in 2017 and expected to be popular among new buyers who have flocked from sedans to SUVs in huge numbers. The company said on its last quarterly analyst call in January that it would be shipping the vehicles earlier than expected, boosting the company’s already high stock price. Tesla on Monday announced that Model Y deliveries had begun.

The rollout was important because Tesla has previously struggled to deliver new vehicles as it shifted production. The company was slow to meet production targets for its Model 3 sedan, prompting concerns about its initial ability to meet mass-market demand.

The move to keep the assembly line going prompted rebukes from Tesla critics, who said it was a reckless decision prioritizing a dubious short-term benefit over the long-term impact on the company and region. Tesla’s stock sunk about 16 percent by the day’s closing, outpacing average market losses for Wednesday. The stock was trading at $361, more than $600 lower than an all-time intraday high set in February.

Tesla also appears to be alone among major American automakers in keeping its factory running. Detroit’s Big Three automakers, General Motors, Ford and Fiat Chrysler, announced Wednesday they would close their plants until at least the end of the month, following a push from their United Auto Workers-backed workforces.

Tesla previously resisted workforce efforts to unionize, drawing accusations of union-busting. A judge ruled in September that the company violated federal labor law by targeting union activity at its plant.

Musk is infamous for implementing a hustle-oriented culture at Tesla, including runs he called “production hell” and “delivery logistics hell.” He’s known to sleep in the factory during busy times and has even put up workers in a tent at the plant to handle production needs.

According to the Alameda County Public Health Department order issued Monday, businesses can engage in the “minimum necessary activities to maintain the value of the business’s inventory, ensure security, process payroll and employee benefits” and related matters. The company also can continue the “minimum necessary activities to facilitate employees of the business being able to continue to work remotely [from] their residences,” according to the order.

Scott Galloway, a New York University Stern School of Business professor of marketing and frequent critic of Musk, said the CEO was putting employees and the company itself at risk with his decision. He said the situation reflected the lack of a governance structure to rein Musk in.

“I think every CEO has to make a decision between the economic well-being of the company and the risk you’re subjecting your employees to in the longer term, while opening the company to legal liability,” he said. “I would argue that the downside risk he’s subjecting himself and his shareholders to is much bigger than the upside.”