PALO ALTO (AP) — Record electric vehicle sales last summer amid a shortage of computer chips and other materials propelled Bay Area-based automaker Tesla Inc. to the biggest quarterly net earnings in its history.

The company said Wednesday that it made $1.62 billion in the third quarter, beating the old record of $1.14 billion set in the second quarter of this year. The profit was nearly five times larger than the $331 million Tesla made in the same quarter a year ago.

READ MORE: New COVID Variant 'Omicron' Identified In San Francisco; Here's What You Need To Know

Revenue of $13.76 billion from July through September also set a record, but it fell short of Wall Street expectations of just over $14 billion, according to FactSet.

Excluding special items such as stock-based compensation, Palo Alto, California-based Tesla made $1.86 per share, beating analyst estimates of $1.62. CEO Elon Musk has said he’s moving the headquarters to Austin, Texas, the dateline of Wednesday’s earnings release.

Some of the quarterly profit, though, came from selling regulatory credits to other automakers. Tesla made $279 million on credits during the quarter. Other automakers buy the credits when they can’t meet emissions and fuel-economy standards.

“A variety of challenges, including semiconductor shortages, congestion at ports and rolling blackouts, have been impacting our ability to keep factories running at full speed,” the company said in a statement to shareholders. “We believe our supply chain, engineering and production teams have been dealing with these global challenges with ingenuity, agility and flexibility that is unparalleled in the automotive industry.”

Earlier this month Tesla said it delivered a record 241,300 electric vehicles in the third quarter even as it wrestled with the shortages that have hit the entire auto industry. Previously, Musk has said Tesla kept its manufacturing lines running largely by finding chips from alternate suppliers and then scrambling to rewrite some of the software in its cars to ensure all the technology remained compatible.

Third-quarter sales rose 72% over the 140,000 deliveries Tesla made for the same period a year ago.

So far this year, Tesla has sold around 627,300 vehicles. That puts it on pace to soundly beat last year’s total of 499,550.

While sales grew in the third quarter, the average sales price fell 6% because Tesla is selling more less-expensive Models 3 and Y and fewer pricier Models S and X.

READ MORE: Bay Area Music Icon Carlos Santana Undergoes Heart Procedure; Cancels December Shows

Tesla also took an impairment charge of $51 million due to a decline in value of its Bitcoin holdings.

Wedbush analyst Daniel Ives wrote in a note to investors that Tesla’s deliveries and earnings are impressive despite an overhang from the shortage of automotive computer chips. He wrote that demand is outstripping supply for Tesla and that Wedbush believes the chip shortage took about 40,000 vehicle sales off Tesla’s numbers so far this year.

Still, he predicts Tesla will hit about 900,000 in sales this year and about 1.4 million in 2022.

The company said in its statement that construction of its new factory near Austin is progressing as planned and it’s preparing equipment and “fabricating our first pre-production vehicles.”

The factory, which is centrally located versus Tesla’s other assembly plant in Fremont, California, will send Model Y small SUVs and new Cybertruck pickups to East Coast population centers.

Tesla said it expects to expand its factory capacity quickly, and over a “multi-year horizon” it expects sales to grow an average of 50% annually.

“The rate of growth will depend on our equipment capacity, operational efficiency and the capacity and stability of the supply chain,” the company said.

Tesla said its factory in China continues to be its main source of exports. It plans to change to a lithium iron phosphate battery chemistry globally for standard range vehicles.

MORE NEWS: Newsom: Prosecute Smash-And-Grab Shoplifters Under Existing Laws

Shares of Tesla Inc. fell 0.5% to $861.14 in after-hours trading Wednesday.