"Challenges remain, but this is a step in the right direction," said Wedbush analyst Dan Ives. "The numbers were above even the bull estimates and shows a clear rebound for the company. This is a feather in the cap for Tesla."

Tesla's deliveries are a closely watched industry number and the nearest reflection of sales, showing how many cars were actually delivered to customers.

CEO Elon Musk set investors' expectations high in a companywide email on June 25, saying the electric car maker was on course to deliver a record number of vehicles throughout the quarter. He wasn't exaggerating. The company delivered 95,200 cars during the the three months ending June 30 — a 51.1% increase over an admittedly weak first quarter and besting its previous record of 90,700 deliveries set in the fourth quarter of 2018.

The electric car maker released its delivery and production results Tuesday night, hinting at a strong third quarter that already has a backlog of orders. The news sent its shares soaring by almost 8% before the markets opened.

Tesla's stock surged in premarket trading Wednesday after the electric auto maker said it shattered its previous production and delivery records during the second quarter, soundly beating analysts' estimates.

Tesla's deliveries also blew away analysts' estimates of 91,000, according to data compiled by FactSet. A disappointing 63,000 vehicles were delivered during the first three months of the year, when Tesla was plagued by challenges transporting cars from its factory in Fremont, California, across the world as well as questions about waning customer demand.

"In addition, we made significant progress streamlining our global logistics and delivery operations at higher volumes, enabling cost efficiencies and improvements to our working capital position," the company said in announcing its results.

Tesla's orders aren't fully reflected in its delivery numbers until a buyer takes possession of their new car. The company said 7,400 vehicles were still in transit, but not yet delivered, during the second quarter. Those sales will show up in its third-quarter report.

Tesla is facing increased competition for the high-end electric sports car market as automakers from Ford to Jaguar invest billions of dollars to develop their own electric lineups. Volkswagen and Mercedes-Benz began taking orders in May for new battery-electric vehicles with plans to roll out more models in the coming years. Jaguar's I-Pace all-electric SUV swept industry awards at the New York Auto Show in April.

Deliveries for the company's biggest seller, the Model 3, were 77,550 compared with 74,100 estimated by analysts. Combined deliveries for the Model S sedans and Model X SUVs were 17,650, also beating estimates of 16,600, according to FactSet data.

"Delivery numbers are important, but we need to see the tea leaves look good for the second half," Ives said in an interview. Tesla's production target for the year is "still an Everest task, especially with competition coming at them from all angles. The real question is going to be, is this sustainable?"

Tesla told investors in April it expected to "deliver between 90,000 and 100,000 vehicles in Q2. Although it is possible to deliver a higher number of vehicles."

The company also recently lost one of its top manufacturing executives at its Fremont plant, Peter Hochholdinger, who was vice president of production.

Tesla's stock has lost almost a third of its value over the last year and the company's market cap is at about $40 billion.

— CNBC's Lora Kolodny contributed to this article.