A Tesla electric car that mainstream drivers can afford has finally arrived, Elon Musk’s automaker said Thursday, achieving a long-delayed promise that could help propel the upstart automaker into the American middle-class garage.

But to help get the Model 3 sedan’s price tag down to $35,000, the company said it will close many of its nationwide stores, laying off an undisclosed number of employees and shifting all car sales online.

“It’s excruciatingly difficult to make this car for $35,000 and still be financially sustainable,” Musk said Thursday.

The change will fulfill a pledge long regarded as dubious for the Model 3, America’s best-selling electric car, which was first introduced with a $35,000 price tag in 2016 but has been sold since then only at higher prices due to what Musk has called a “hellish” series of financial struggles and manufacturing delays.

The cost-cutting and mass layoffs, however, show how the company has not fully moved past the financial doubts that have dogged its early years. Musk said that he wished “there was some other way” to offer the car at a lower price without layoffs and that the company did not expect to make a profit this quarter. Tesla stock fell about 3 percent in after-hours trading.

A Tesla ordering page says the $35,000 “standard range” Model 3 would be able to drive 220 miles on a single charge and be delivered within two to four weeks. That puts it in line with other electric competitors: The 2019 Chevy Bolt, which starts at $36,000, can drive about 238 miles, while the $30,000 Nissan Leaf can go about 150 miles.

The entry-price Model 3 comes in one color: “solid black.” Other Model 3 colors and makes with bigger batteries, upgraded interiors or all-wheel drive will sell for higher prices.

Musk said the company will shift all of its sales online, a cost-cutting measure that will further distance Tesla from the dealership model that dominates the auto industry.

“Worldwide, the only way to buy a Tesla will be online, and you can buy a car on your phone in one minute,” Musk said Thursday. “It’s 2019; people want to buy things online."

The move will help the company lower vehicle prices by an average of 6 percent, he said, but will also result in an undetermined number of layoffs and store closures. Some stores will transform into “galleries and information centers” open for prospective buyers’ questions.

The affordable Model 3 has for years been Tesla’s holy grail, a long-promised, long-unreachable key to unlocking a potentially vast mass-market clientele. In 2006, when his company was known only for its Roadster luxury sports car, Musk said making affordably priced family cars was Tesla’s “secret master plan” to turning a profit and weaning the world off fossil fuels.

“While later than expected, Tesla has delivered on its promise,” Karl Brauer, executive publisher at Kelley Blue Book and Autotrader, said in an email. “If Tesla can do this it will have successfully transitioned from a boutique automaker with a niche audience to mainstream brand serving mainstream consumers.”

The originally promised price of $35,000 helped make Tesla a household name. After Musk introduced the car in 2016, more than 400,000 buyers paid to put their name on a reservation list.

But once the car began rolling off the Tesla factory line in summer 2017, its manufacturing was marred by months of what Musk famously labeled “production hell.” Delays from the Tesla factory’s overreliance on finicky robots, among other woes, dramatically limited how many cars could be made and threw the company into financial limbo.

Tesla last summer announced it had reached its goal of making 5,000 Model 3 sedans a week, but the only ones offered for sale were at luxury prices, turning many buyers away. Musk tweeted in May that selling the car for $35,000 would “cause Tesla to lose money & die.”

On Thursday, Tesla’s website also claimed that “full self-driving capability” would be “coming later this year.” The company’s Autopilot software currently handles some limited tasks, such as highway driving, but can’t drive the full way from start to finish.

On a Thursday call with journalists, Musk declined to answer questions about a $920 million convertible bond due Friday. The company has said it will repay the debt, helping to calm a lingering investor concern about whether Tesla had enough cash to cover it. Billions of dollars in other debts will come due in the next several years.

Musk, flexing his signature showmanship and nerd mystique, dropped what seemed to be odd hints earlier in the week, promising to break news on Thursday and changing his Twitter name to “Elon Tusk.” On Thursday afternoon, the Tesla website temporarily removed its order pages and posted a page announcing, “The wait is almost over.” The stunt sparked an industry-wide guessing game over the latest surprise of America’s most perplexing major automaker.

Tesla has worked to speed up the Model 3′s production and delivery, including by rerouting the production lines of its other more expensive models, but the Model 3′s recent price tag of about $45,000 had led some analysts to question whether the company would be able to gin up enough demand.

Tesla said it delivered more than 90,000 vehicles in the last quarter of 2018, three times as many as it delivered in the same period in 2017, but that it must reach more customers who can afford its cars if it wants to grow and compete.

In October, Musk announced that Tesla would sell a “mid-range” Model 3 — powered by a smaller battery, allowing it to drive fewer miles on a single charge — for about $45,000. But he added last month that “our products are still too expensive for most people.”

Musk’s announcement comes just days after the Securities and Exchange Commission took him to task for violating the terms of a major settlement last year, in which Musk agreed to have his tweets and other public statements preapproved by a Tesla attorney.

A federal judge on Tuesday ordered Musk to explain within the next two weeks why he should not be held in contempt for breaching the deal. Musk’s sparring with regulators — including telling a TV interviewer he doesn’t “respect the SEC” — has baffled some investors and raised worries that he or the company could face severe new penalties.