Tesla founder Elon Musk stepped on the accelerator, delivering the biggest-ever sales quarter for the electric-car maker, despite recent distractions.

Tesla Motors — whose charismatic chief executive week unveiled plans to go to Mars with his Space X company — said Sunday it more than doubled third-quarter sales, to 24,500 units, from last year.

That was better than most analysts expected, including Brad Erickson of Pacific Crest Securities, who last week forecast 22,000 deliveries. Some Tesla’s sales centers were discounting cars in the final days of the quarter to meet targets, he said, as a reason for his bearish outlook.

Musk sent an e-mail to employees last week, banning discounts on all brand-new, undamaged cars, including to “my family, friends and celebrities, no matter how famous or influential.”

Tesla’s strong numbers come as Musk is making a controversial bid to merge with SolarCity, a solar-panel installer co-founded by Musk’s cousins, Lyndon and Peter Rive. Musk, meanwhile, has been grappling with the aftermath of a fatal crash in June in Florida of a Model S driver who was using Autopilot mode.

Tesla said Sunday it shipped 15,800 Model S sedans in the quarter, and 8,700 Model X SUVs. Tesla said the third-quarter delivery count “should be viewed as slightly conservative,” as it has an additional 5,500 vehicles in transit to customers that will be counted towards fourth-quarter numbers.

For the final quarter of 2016, Tesla expects deliveries to be “at or slightly above Q3.”

As such, Tesla said it remains on track to crank out 50,000 vehicles during the second half of 2016 — a feat that would meet Tesla’s most recent goal to deliver between 80,000 and 90,000 cars this year.

To get the job done, Tesla lately has introduced a two-year leasing option for both the Model S and Model X. It also launched a new, souped-up version of the Model S, the P100D, which in “Ludicrous Mode” can go from zero-to-60 mph in 2.5 seconds, making it the fastest current mass production car in the world.

Still, Tesla remains well short of producing the 500,000 cars it aims to crank out in 2018, after launching its upcoming Model 3, which is targeted for the end of next year.

Tesla’s Sunday announcement made no mention of profitability. In an August memo to employees, Musk wrote that “the third quarter will be our last chance to show investors that Tesla can be at least slightly positive cash flow and profitable before the Model 3 reaches full production.”

Once the fourth quarter begins, capital spending to ramp up the Model 3 — a car that’s priced more affordably, at $35,000 — will force Tesla’s cash flow “into a negative position” until the Model 3 reaches full production in late 2017, Musk said.

Tesla shares, down 15 percent this year, rose 1.7 percent, to $204.03, on Friday.