Tesla shares are surging — and short sellers are hurting.

Wall Street investors betting against Tesla’s stock got clobbered to the tune of nearly $1.5 billion on Thursday after Elon Musk’s electric-car maker reported a surprise profit, giving the company’s shares their biggest boost in six years.

Tesla bears — which include big-name money managers like Jim Chanos and David Einhorn — got caught after Tesla reported a third-quarter profit of $1.86 a share on improved efficiencies at its factory. Tesla also said it expects deliver as many as 400,000 cars this year and that it was ahead of schedule on a new car plant in China.

The news lifted Tesla shares nearly 18% to $299.68, giving the company a market capitalization of $53 billion — edging past General Motors to become the nation’s most valuable car company.

It was a miserable day for short sellers, who lately had been booking healthy gains on bets that the stock would fall, according to S3 Analytics.

The research firm calculated that short sellers’ collective, year-to-date gains got slashed on Thursday to $525 million, or about 6%, from a high of $2 billion earlier this year.

“This was the worst loss that we’ve seen” for Tesla’s short sellers, S3’s managing director, Ihor Dusaniwsky, told The Post.

Investors that have placed short bets against Tesla more recently were the ones who had the most to lose, he noted, while long-term bears were more likely to still be in the black.

Chanos and Einhorn, who haven’t disclosed the size of their Tesla short bets, didn’t respond to requests for comment. But on Thursday Chanos struck a defiant tone on Twitter, claiming that Tesla was “fundamentally unprofitable.”

Previously, Einhorn had bashed Tesla cars for being less safe than the company claims as a rationale for his short bet. “The wheels are falling off — literally,” he said earlier this year in an investor letter, according to CNBC.

While Einhorn got pummeled Thursday, critics note that Musk also has a spotty track record when it comes to delivering on his bold promises. Analysts at JPMorgan said they are “unsure that this is really the breakout quarter that is likely to be claimed by the bulls,” according to a Thursday analyst note.

To be sure, Tesla still has plenty of lost ground to recover. Even after Thursday’s surge, its shares are 22% lower than its all-time high of $383.45 reached in June 2017. Since then, the shares have gotten battered on a slew of flubs by Musk, including his misleading tweet in August 2018 that he had “funding secured” to take the company private.

After Apple, Tesla is the second-most shorted stock in the US, with about $8.3 billion — or 20% — of its shares shorted by investors, according to S3.

Nevertheless, that percentage is down from 24 percent in June and a whopping 60% in 2012.