Tesla posted a surprising profit of $143 million in its latest quarter, raising hopes the electric car pioneer may finally be turning the corner after posting mostly losses during its first decade as a publicly held company.

The positive results announced Wednesday came after Tesla lost $1.1 billion during the first half of the year. That had caused many investors to lose faith in the company even as it boosted sales of its vehicles.

Doubts about Tesla led its stock to fall by 23% so far this year, while the bellwether Standard & Poor’s 500 index has climbed 20%. But Tesla’s shares recovered a big chunk of those losses after its third-quarter numbers came out, soaring 20% to $306 in extended trading.

The rally stemmed largely from investors’ surprise given the widespread expectation on Wall Street that Tesla would register yet another significant loss for the July-September period. Analysts surveyed by FactSet had projected Tesla would lose about $253 million during the third quarter.

Instead, Tesla delivered a “jaw dropper,” said Wedbush Securities analyst Daniel Ives. “The Street wanted profitability and Tesla delivered in big fashion.”

The performance represents a measure of vindication for Tesla’s enigmatic co-founder and CEO Elon Musk, who has been facing more questions about whether he is the right person to be steering the company at this critical juncture.

Seemingly emboldened, Musk reiterated a pledge to sell at least 360,000 vehicles this year. Tesla will have to sell about 105,000 cars during the final three months of the year, after delivering a record 97,000 vehicles in the third quarter.

Boosting sales even more in the current quarter is something most analysts have been doubting Tesla will be able to pull off, but that mindset may change after the company’s financial breakthrough in the past quarter.

But Tesla will still have to prove it can sustain the momentum, something that it hasn’t done so far. For instance, the company recorded back-to-back quarterly profits last year, only to sustain huge losses during the first half of this year even as it sold more cars.

The company fared better during the same time last year with a profit of $311 million. That means the net income for this year’s quarter was down 54% by comparison.

Tesla probably would have lost money again in the past quarter if not for mass layoffs and other cost-cutting measures that Musk has imposed this year as he faced mounting pressure to make money.

The company’s operating expenses in the past quarter decreased 16% from last year to $930 million.

In a Wednesday conference call, Musk promised to remain “highly focused” on reaching decisions that help bolster the company’s long-term prospects.

Even so, the electric automaker will almost certainly post yet another annual loss this year, just as it has done every year since its initial public offering in 2010. Since then, Tesla has amassed more than $5.5 billion in losses.

More financial potholes could still be looming as Tesla faces increasing competition, with more automakers rolling out their own electric vehicles to cater to the growing number of consumers looking for alternatives for fuel-burning vehicles. Many of those automakers will be able to take advantage of alluring tax incentives that are now being phased out for Tesla because of its head start in the field.

“We have passed peak Tesla, it has already seen its best days,” asserted David Kudla, chief investment strategist for Mainstay Capital Management, a financial advisory firm that focuses on the auto industry.

© The Associated Press. All rights reserved.