Looks like billionaire entrepreneur and Tesla CEO Elon Musk just got his wish.
Weeks after sending an email to the electric car company’s staff, imploring them to help the company show it can be profitable and cash flow positive in its third quarter, Tesla announced its first quarterly profit in three years on Wednesday afternoon.
Tesla (TSLA) said in a letter to shareholders that it generated $21.88 million of net income, according to generally accepted accounting principals. That’s compared to a $229.86 million loss for the same quarter in 2015.
The company also said it has $176 million of positive free cash flow.
Get Data Sheet, Fortune’s technology newsletter.
Tesla has spent much of the past year working toward this goal, while at the same time spending heavily to grow its manufacturing and to launch a new car.
At the same time, Tesla also changed the way it reported earnings for this quarter. The company is phasing out many of the non-GAAP adjustments it’s traditionally made, and it’s a move that can make the company’s earnings look better than they’ve previously been.
The positive earnings—it’s first since 2013 for the 13-year-old company—is thanks to record electric car shipments of 24,821 for the quarter, or about 300 more than the company announced a couple weeks ago.
The company says that because of the strong quarter, Tesla is still on track to deliver 50,000 cars in the second half of this year, and close to 80,000 cars for the full year.
Tesla Reports Better Sales Than Its Competitors
The profit comes on third quarter revenue of $2.30 billion, which is more than double its revenue of $936.79 million from the same quarter last year.
The blockbuster quarter comes at a crucial time for Tesla as it’s been spending heavily in an effort to grow its car manufacturing dramatically, from 80,000 cars this year to 500,000 cars by 2018. Tesla also plans to start delivering its next car, the Model 3, by the end of 2017.
To meet those goals, Tesla has been building a massive battery factory outside of Reno, Nevada, which will make batteries for its Model 3 car. Tesla has also been expanding its factory in Fremont, Calif.
Tesla could possibly raise more debt and equity next year to help it fund this growth. This strong quarter is critical to help Tesla raise those funds.
As a result of the good news, Tesla’s stock jumped close to 6% at one point in after hours trading.
Tesla is still spending heavily to meet its goals. The company said its operating expenses for the quarter were $551 million. Tesla expects to spend $1.8 billion in capital expenditures in 2016.