Tesla founder Elon Musk presenting the new Roadster electric sports vehicle (on background), presented to media on Nov. 16, 2017 at Tesla's Los Angeles design center. Tesla says the Roadster will accelerate from 0-60 mph in less than two seconds. Tesla says the new Roadster will cost $200,000 and will be released in three years. /TESLA HANDOUT VIA EPA-EFE

SpaceX's newest rocket, the Falcon Heavy, the most powerful rocket in the world, lifts off on it first demonstration flight. The rocket leapt off Pad 39A at the Kennedy Space Center in Florida at 3:45pm. on Feb. 6, 2018. CRAIG BAILEY/FLORIDA TODAY VIA USA TODAY NETWORK

This image from video provided by SpaceX shows Elon Musk's red Tesla sports car with a dummy driver named "Starman" which was launched into space during the first test flight of the Falcon Heavy rocket on Feb. 6, 2018. /SPACEX VIA AP

President Trump talks with Tesla and SpaceX CEO Elon Musk, center, and White House chief strategist Steve Bannon during a meeting with business leaders in the State Dining Room of the White House in Washington, Feb. 3, 2017. EVAN VUCCI/AP

Tesla Motors CEO Elon Musk speaks about the Interplanetary Transport System which aims to reach Mars with the first human crew in history, in the conference given by Tesla Motors CEO Elon Musk during the 67th International Astronautical Congress in Guadalajara, Mexico on September 27, 2016. HECTOR-GUERRERO/AFP/GETTY IMAGES

Tesla Motors CEO Elon Musk unveils the Model X at a launch event in Fremont, Calif on Sept. 29, 2015. The Tesla Motors X is an all-wheel drive SUV featuring a 90 kWh battery providing 250 miles of range and will be able to go from 0 to 60 mph in 3.2 seconds. ROBERT HANASHIRO/USA TODAY

SpaceX CEO Elon Musk unveils SpaceX's new seven-seat Dragon V2 spacecraft, in Hawthorne, California on May 29, 2014. The private spaceflight companys new manned space capsule is designed to ferry NASA astronauts to and from the International Space Station. The capsule was named for "Puff the Magic Dragon," a jab at those who scoffed when Musk founded the company in 2002 and set the space bar exceedingly high. SpaceX went on to become the first private company to launch a spacecraft into orbit and return it safely to Earth in 2010. ROBYN BECK/AFP/GETTY IMAGES

Tesla Motors president and CEO Ze'ev Drori, left, and Tesla Motors chairman Elon Musk, right, pose in the Tesla Motors development facility in San Carlos, just south of San Francisco next to a Tesla Roadster on Feb. 19, 2008. The Tesla Roadster, a $99,000 electric sports car powered by laptop computer batteries, is 100 percent electric, can go from 0-60 mph in four seconds and the electric car gets an equivalent of 135 mpg compared to a gas powered vehicle. Production begins mid-March. The car itself is being made in England. JACK GRUBER/USA TODAY

Tesla delivered a rare quarterly profit as the company ramped up production of its Model 3 electric car, inching closer to financial sustainability even as big-ticket spending items linger in the near future.

The Palo Alto, Calif.-based automaker reported net income of $312 million in the third quarter, a year after reporting a net loss of $619 million.

The profit comes as Tesla racks up cash from sales of the Model 3 electric sedan, its most important vehicle yet because it is the first aimed at the mass, not luxury, market. While the ramp-up of manufacturing took longer than usual for a car company, the pace of production has improved along with Tesla's finances.

Third-quarter total revenue soared from $2.98 billion a year ago to $6.82 billion.

"Sufficient Model 3 profitability was critical to make our business sustainable – something many argued would be impossible to achieve," Musk said in a letter to investors.

To be sure, profitability may not last for long. The company is investing in a new plant in Shanghai to make electric cars for China and it is also expected to spend to deliver a new electric crossover called the Model Y within the next few years. Tesla has also outlined other costly ambitions, including production of an electric semi-truck and sports car.

Musk said he "recently" approved the Model Y prototype to go into production with a goal of making the vehicle in high volumes in 2020.

A more immediate question is whether Tesla will offer cheaper Model 3 versions soon and whether it can continue making money when it does. In the third quarter, Model 3 carried a starting price of $49,000.

The company still intends to deliver the Model 3 at its originally promised starting price of $35,000. Musk said it could be ready as soon as February, but the company is not currently able to make the battery pack for it.

"We’re trying to provide as many affordable electric car options as we can," Musk said on a conference call.

But Tesla said it expects to continue wringing excess costs out of vehicle production. "While the average selling price will gradually decline as we introduce lower-priced variants, we are not expecting this to impact profitability," Musk wrote.

The company sped up electric-vehicle production to 80,142 vehicles during the third quarter, including 53,239 Model 3 units.

Overall, the total output marked a 50 percent increase from the second quarter, which was the company's previous high.

Vehicle deliveries — what the rest of the auto industry would typically label as vehicle sales — totaled 83,500 for the quarter, including 55,840 Model 3 cars.

In the "long term," Musk predicted that global demand for the Model 3 would hit 500,000 to 1 million cars annually.

The company expects to begin European sales of the Model 3 in the first quarter of 2019 and Asia sales soon thereafter, Musk said. The car is currently sold only in North America.