Tesla Motors Inc. (TSLA) reported a net loss of $31 million in the second quarter, but the Palo Alto, Calif., electric-car maker improved gross margins, increased production and beat most Wall Street analysts' expectations.

Tesla shares, which had closed Wednesday down 5.6% at $134.23, jumped 11.5% to $149.85 in after-hours trading.

Tesla said it lost $11.79 million from operations, before interest and taxes, during the quarter. Revenue declined by more than $150 million, mainly because the company had to defer some revenue associated with cars delivered under a new financing program for Model S sedans designed to mimic a lease. The hybrid purchase/lease financing accounted for 30% of the auto maker's sales volume in the April-to-June period.

Revenue for the quarter was $405 million, down from $561 million in the first quarter. Deliveries increased by 5% from the first quarter to 5,150 cars.

Investors focused on other numbers in Tesla's report. Tesla Chief Executive Elon Musk, in a letter to shareholders, affirmed that the company can deliver about 21,000 cars this year and said it is on track to achieve 25% gross margins for the year.

In the second quarter, it cost Tesla about 22% less to build a car than it received in revenue. That gross margin was up from 17% in the first quarter.

Tesla has been among the hottest stocks in the U.S. since posting an $11 million net profit in the first quarter of 2013. Investors have gobbled up shares in the company as the reception to its first full-line vehicle has been strong, and some believe the company could revolutionize the car industry.

Write to Mike Ramsey at michael.ramsey@wsj.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires

Tesla (NASDAQ:TSLA)
Historical Stock Chart
From Apr 2024 to May 2024 Click Here for more Tesla Charts.
Tesla (NASDAQ:TSLA)
Historical Stock Chart
From May 2023 to May 2024 Click Here for more Tesla Charts.