Tesla Motors (TSLA) swung to a loss in the first quarter, but the electric car maker still managed to beat expectations amid higher sales.

After the closing bell Wednesday, Tesla reported a loss of $49.8 million, or 40 cents a share, compared to a year-ago profit of $11.3 million, which broke even on a per-share basis. Adjusted earnings remained level at 12 cents a share.

Revenue rose 10.5% to $620.5 million. On an adjusted basis, revenue was up 27% at $713.1 million.

Analysts projected non-GAAP earnings of 10 cents a share and revenue of $699.1 million.

Tesla was one of 2013’s high-flying stocks and is up 33.9% since the start of this year. The company has provided an upbeat outlook for sales of its Model S sedan, and earlier this year, Tesla detailed plans to ramp-up production and expand its model lineup. A less expensive Model X crossover is expected to go on sale by the spring of 2015.

Shares fell 5.9% to $189.47 in after-hours trading following Tesla’s earnings report, which was hampered by rising costs.

Research and development expenses surged 49% to $81.5 million, while selling, general and administrative costs more than doubled to $117.6 million.

Tesla said it booked a $2 million reserve to cover the cost of adding titanium underbody shields to the Model S. The move came in response to high-profile fires involving the vehicle.

Tesla said it produced 7,535 Model S vehicles in the first quarter and delivered 6,457. That puts the company on pace to surpass its target of 35,000 deliveries of the Model S in 2014, which would reflect a 55% gain over the prior year.

Palo Alto, Calif.-based Tesla also expects to book an auto gross margin of 28% by year’s end. In the first quarter, margins checked in at 25.3%, or 25.4% on an adjusted basis.

Investors are also keeping a close eye on Tesla’s plans to build a large battery factory, which it has dubbed a “Gigafactory.” The plant will lower the cost of battery modules and ramp up production starting in 2017, according to Tesla.

On Wednesday, the company said it plans to eventually start work on at least two locations to prevent any delays after groundbreaking. Tesla has considered sites in Arizona, New Mexico, Texas and Nevada.

Tesla also expects to launch its Model S in the U.K., Japan and Hong Kong this summer.

“We still plan to invest $650-850 million for the year in capital expenditures for increased production capacity, growth in our store, service center and Supercharger footprints, Model X and S development and start of Gigafactory construction,” chairman and CEO Elon Musk said in a letter to shareholders.

Follow Matthew Rocco on Twitter @MatthewRocco