Tesla racked up a $619 million loss in the third quarter, its biggest-ever, driving its shares sharply lower as the electric-car maker spends to speed up production of its more affordable Model 3 sedan.

The company, led by Silicon Valley star Elon Musk, also confirmed it had missed its Model 3 production goal for the third quarter, producing only 260 vehicles compared to an earlier estimate of 1,500.

Its shares fell 5.4 percent in after hours trading.

Scroll down for video

Elon Musk confirmed it had missed its Model 3 production goal for the third quarter, producing only 260 vehicles compared to an earlier estimate of 1,500

The company said it had $3.53 billion in cash and cash-equivalents as of Sept. 30, compared to $3.04 billion at the end of the second quarter.

Tesla said last month it delivered 26,150 vehicles in the third quarter, a 4.5 percent rise on the same period of 2016, but added that "production bottlenecks" had left the company behind its planned ramp-up for the $35,000 Model 3.

On Wednesday it said it now hoped to achieve a production rate of 5,000 per month by the end of the first quarter of next year, pushed back from the end of this year.

It said automotive gross margin, which excludes the sale of zero emission vehicle (ZEV) credits, fell to 18.7 percent from 25 percent last year.

Elon Musk has likened future versions of Tesla's Model 3 production line to an 'alien dreadnaught' -but has admitted the firm is 'in production hell'

Analysts on average had expected margins of 18.4 percent, according to FactSet.

Led by Silicon Valley entrepreneur Elon Musk, Tesla is struggling to overcome production bottlenecks as it builds the Model 3, seen as key to the company's long-term profitability.

The company said in October it missed its Model 3 production goal for the third quarter, producing only 260 vehicles compared with an earlier target of 1,500, and Musk said last month the car was "deep in production hell".

Tesla posted a net loss of $619.4 million, or $3.70 per share, for the third quarter ended Sept. 30 compared to a profit of $21.9 million, or 14 cents per share, a year earlier.

Revenue rose 30 percent to $2.98 billion. Excluding items, the company lost $2.92 per share.