Tesla posts rare profit, stock pops 6%

Testing Tesla's handsfree driving

Tesla just unveiled one of its most unusual feats yet: turning a profit.

Tesla (TSLA) posted a profit of $22 million for the third quarter, a rare event for the car company. It’s much improved from the $230 million loss it reported in the same quarter a year earlier.

The stock was up 6% in after hours trading Wednesday following the results.

In late August, CEO Elon Musk sent an e-mail to Tesla employees imploring them to slash costs and “deliver every car we possibly can” in a mad dash to turn a profit.

“The third quarter will be our last chance to show investors that Tesla can be at least slightly positive cash flow and profitable before the Model 3 reaches full production,” Musk wrote in the email.

For Musk, this quarter’s results are about more than bragging rights.

Related: Elon Musk’s push for autopilot unnerves some Tesla employees

Tesla will likely need to raise more money to finance the production of the Model 3, its first mass market car, and build its ginormous Gigafactory. The car company expects to invest billions on each effort.

Musk is also trying to convince shareholders to approve Tesla’s acquisition of SolarCity (SCTY), another company with Musk as a chairman and large investor. Like Tesla, it’s also a business that typically loses money.

By showing Tesla can be profitable, Musk may be able to make these ambitious efforts easier to swallow on Wall Street.

Tesla previously announced it shipped 24,500 vehicles during the September quarter and remains on track to ship 50,000 cars in the second half of this year. That’s roughly as many as Tesla delivered in all of 2015.