Tesla posted a narrower-than-expected second-quarter loss Wednesday, boosted by revenue that nearly doubled.

The strong revenue was driven by deliveries of its Model S sedans and Model X SUVs, helping to relieve investor concerns that the upcoming Model 3 was cannibalizing sales of its higher-end models.

Here's how the company did compared to what Wall Street expected:

Adjusted loss per share of $1.33 vs. $1.82 expected, according to Thomson Reuters

Revenue: $2.79 billion vs. $2.51 billion expected, according to Thomson Reuters

Tesla's reported a net loss of $336 million, or $2.04 per share, compared to a loss of $293 million, or $2.09 a share, a year ago.

Excluding stock based compensation, Tesla lost $1.33 a share, which was narrower than expected, according to a consensus estimate from Thomson Reuters.

Revenue climbed to $2.79 billion from $1.27 billion in the year-ago period, and outpacing Wall Street's estimates of $2.51 billion.

Shares surged roughly 8 percent in after market trading. Since the start of the year, Tesla shares have gained 52 percent, as investors anticipate the launch of its first car for a more mainstream consumer.

Heading into the earnings report, analysts expressed concerns about whether Tesla would ramp up production of its Model 3, a more affordable electric car with a base cost of $35,000, quick enough. In the past, Tesla has struggled with production issues.

In the release Wednesday, Tesla reaffirmed that it remains on track to hit its previously announced targets.

"What people should absolutely have zero concern about, zero, is that Tesla will achieve a 10,000 unit production week by the end of next year" said Tesla CEO Elon Musk on a conference call following the release.

On Friday, when it handed over the keys to the first Model 3 sedans to employees, Tesla said reservations for the car had grown to more than 500,000. Since that time, Tesla said it is averaging over 1,800 net Model 3 reservations a day.

In a letter to shareholders, Tesla said the first deliveries were "a huge milestone for Tesla and is very exciting for our entire team."

The company expects to begin deliveries of the Model 3 to non-employees in the fourth quarter. It is aiming for international Model 3 deliveries to begin in late 2018, starting with left-hand drive markets. Right-hand drive markets won't likely have deliveries until 2019.

"We have learned many valuable lessons from designing and manufacturing Model S and Model X. Consequently, Model 3 is designed with greater simplicity and fewer components to reduce cost, improve ease of manufacturability and further enhance reliability," the company said in its statement.

Tesla expects to be able to produce 1,500 vehicles in the third quarter, and achieve a run rate of 5,000 vehicles per week by the end of this year. At some point next year, Tesla hopes to boost production to a rate of 10,000 Model 3s per week.

Tesla expects the Model 3 will have a positive gross margin in the fourth quarter, and it is targeting 25 percent margins in 2018.

Investors also may be encouraged that the company didn't burn through as much cash as it expected. Tesla anticipated capital expenditures would total $2 billion as it ramped up Model 3 production.

However, the company only spent $959 million in capital expenditures in the latest quarter. All told the company said capital expenditures tallied $1.5 billion in the first half, helped by the timing of milestone-based payments.

Tesla ended the quarter with a cash balance of slightly over $3 billion.

However, negative free cash flow was a record $1.16 billion. That is almost double the amount in the first quarter, and suggests Tesla still burning through cash.

As for worries over whether the Model 3 will eat into sales of its higher-end cars, Tesla saw a 53 percent increase in deliveries for its Model S and Model X cars combined compared to the same quarter last year, even though overall industry sales of luxury cars remained flat.

During the second quarter, Tesla delivered 22,026 Model S and Model X cars, for a total of 47,077 in the first half of the year.

The California carmaker expects Model S and X deliveries to increase during the second half of 2017, compared with the first half.

Net gross margins for the automotive business were 27.9 percent and adjusted gross margins were 25 percent.

As for the company's SolarCity unit, it began Solar Roof installations during the quarter at its employees' homes.

Musk said on the call that he is pleased with the look of the roof, but expects its to improve.

"I think this roof is going to look really knockout as we keep iterating" Musk said.

CORRECTION: This article has been revised to reflect that Wall Street expectations for Tesla were for an adjusted loss of $1.82. An earlier headline misstated that fact.