Stay on Top of Emerging Technology Trends Get updates impacting your industry from our GigaOm Research Community

Electric car maker Tesla (s TSLA) Motors delivered a record number — over 5,150 — of its Model S cars to customers in the second quarter, and also disclosed a surprise: better-than-expected earnings, which were announced just after market close on Wednesday. As a result Tesla’s shares jumped over 12 percent in after hours trading to around $150.

Tesla posted a net loss for the second quarter (on a GAAP basis) of $30.50 million, or 26 cents per share. The loss followed on Tesla’s first profit ever (on a GAAP basis) in the first quarter of this year, but was a smaller loss than expected. Gross margin rose to 22 percent (non-GAAP) up from 17 percent last quarter. Tesla CEO Elon Musk said on a call that the company is confident it will get to its goal of 25 percent gross margin later this year.

Revenue dropped in the second quarter partly because of reduced sales of zero emission vehicle (ZEV) credits to automakers. But because increasing production of the Model S significantly from 400 per week to close to 500 per week helped to make up for the ZEV short fall. Tesla said it delivered 600 more Model S cars than expected in the quarter.

Europe got its first Model S cars this week, Tesla said, with the first vehicles going to Norway. Tesla said “in Norway alone, we expect to deliver almost 800 vehicles this year based on current orders.” Tesla also said over the next few weeks it would install its first European superchargers in Norway.

There are now 13,000 Model S cars on the roads in North America, and if demand in Asia matches demand in Europe and North America, Tesla could sell 40,000 Model S cars per year by late 2014, it said.

Interestingly enough, a third of the vehicles delivered in the second quarter took advantage of Tesla’s new leasing/financing program. Tesla also said that it will pilot its battery swapping tech — unveiled in June — in California this year.

Finally, because of strong demand, Tesla plans to spend $150 million in the second half of 2013 on capital expenditures, including buying 31 acres next to its Fremont factory for expansion.

On the call Musk said that Tesla is “hard at work” on the Model X, refining the design, and it expects to deliver small numbers at end of 2014, with volume production in 2015.