DETROIT (Reuters) - Tesla Motors Inc, the California-based maker of luxury electric cars, said it lost $61.9 million, or 50 cents a share, in the second quarter, as revenue nearly doubled to $769.3 million.

On a non-GAAP basis, Tesla said it earned 11 cents a share, topping analysts' expectations of 4 cents. The company expects non-GAAP earnings to be about the same in the third quarter.

In the year-ago quarter, Tesla lost $30.5 million, or 26 cents a share, on revenue of $405.1 million.

Newsweek Magazine is Back In Print

Earlier on Thursday, the automaker announced a partnership with Japanese electronics giant Panasonic Corp to build a $5 billion battery "gigafactory" in the United States.

In its earnings release, Tesla confirmed that it broke ground in June at a site near Reno, Nevada, that could be used for the factory, which is expected to open in 2017.

Tesla built a record 8,763 Model S sedans in the quarter, and delivered a record 7,579 cars to customers, while being "unable to keep pace with increased demand" in North America and Europe.

An expansion at its Fremont assembly plant is expected to give Tesla the ability to build 1,000 cars a week in the fourth quarter and 100,000 cars a year by the end of 2015.

The company plans to launch its third vehicle, the Model X crossover, in spring 2015.

Tesla said it expects to invest up to $950 million this year as it "slightly" accelerates spending on more production capacity and the battery factory. That's about $100 million than previously announced.

Tesla shares rose briefly above $227 after it reported its results, then quickly plunged below $216. They closed at $223.30, down 2.5 percent, in regular trading.