Tesla reported a surprise second-quarter profit Wednesday as it confirmed ambitious targets for 2020 car deliveries despite the coronavirus pandemic and announced plans for a new auto factory in Texas.

The result clears the way for the highflying company led by Elon Musk to potentially join the S&P 500. A requirement for the prestigious Wall Street index is four successive profitable quarters, which Tesla has now achieved.

Tesla shares -- which have exploded in 2020 as the company has met key targets -- climbed further following the results. Several analysts that have praised Tesla's accomplishments view the rise in valuation as excessive.

Musk praised Tesla's staff for "exceptional execution" during a period that included the weeks-long closure of its California plant due to the coronavirus pandemic and said he looked forward to "continue scaling" Tesla up to enable production levels closer to that of conventional auto giants.

"I've never been more optimistic or excited about the future of Tesla," Musk said on a conference call with analysts and investors.

Musk, who has long flouted the unwritten rules of button-down CEOs, avoided the sort of fights with analysts that have occasionally surfaced on conference calls.

But he maintained an informal air throughout the 60-minute session, saying he was interested in hiring "revolutionary actuaries" for an insurance project being developed and effusing about a new factory as an "ecological paradise."

The electric car maker scored profits of $104 million in the quarter ending June 30 compared with a loss of $408 million in the year-ago period.

Revenues fell five percent to $6 billion.

The surprise second-quarter profit of Tesla, whose CEO Elon Musk is seen here in January 2020, positions it to potentially join the S&P 500
The surprise second-quarter profit of Tesla, whose CEO Elon Musk is seen here in January 2020, positions it to potentially join the S&P 500 AFP / STR

Tesla said it was on track to ramp up production at factories in California and Shanghai and that activity on a plant being built in Germany "continues to progress."

The company said delivering 500,000 autos this year "remains our target," effectively reinstating its forecast after withdrawing the figure this spring amid the peak of US coronavirus shutdowns.

Musk said the company had picked a 2,000-acre site near Austin, Texas for its next "Gigafactory" to build a number of models, including the new "Cybertruck" vehicle.

The announcement was greeted by Texas Governor Greg Abbott, who hailed Tesla as "one of the most exciting and innovative companies in the world" and said the factory would add "at least" 5,000 new jobs.

A note from Wedbush Securities said China appeared to be the "star of the show," based on industry data and that demand in the country is "a ray of shining light in a dark global macro" environment.

"This sustained level of profitability is the key for the bulls and speaks to a business model which is staying out of the red ink despite this unprecedented COVID-19 dark storm," Wedbush said.

Tesla executives confirmed that profit margins in China had improved, with Musk pointing to a shift in the supply chain to more locally produced parts as a source of lower costs.

Shares had rallied ahead of the earnings report, in anticipation that the promotion to the S&P 500 would lift demand from investors. But the blowout figures boosted shares further, by 4.4 percent to $1,663 in after-hours trading.

Tesla's share price has risen by more than $1,000 per-share this year, making Musk one of the 10 wealthiest billionaires in the world, according to Forbes, and lifting the company's valuation to many times that of General Motors and other conventional auto giants that sell many times the volume of Tesla.

A note from CFRA Research called the result a "low-quality" beat, citing an unusually large boost from revenues tied to tax credits for electric cars and reiterating its "hold" recommendation on shares.

CFRA has set a target of $1,220 for Tesla shares, implying shares should fall around 25 percent.

"While Tesla once again managed to pull a rabbit out of the hat for earnings, we believe its share price has become decoupled from underlying fundamentals and see growing risks surrounding the story as shares increasingly appear priced to perfection," CFRA said.