Tesla Inc. TSLA -1.27% annual vehicle deliveries surged 87% in 2021, growing at their fastest pace in years, as the company leveraged its Silicon Valley roots to overcome computer-chip shortages that have plagued the global auto industry.

Elon Musk’s electric-vehicle maker said Sunday that it delivered more than 936,000 vehicles globally in 2021, up from nearly half a million the previous year. The company has been aiming to increase annual deliveries by an average of 50%.

Analysts surveyed by FactSet expected Tesla to put roughly 897,000 vehicles in customer hands last year.

Tesla also said it produced roughly 930,000 vehicles in 2021. More than half of those likely were made in ShanghaiCredit Suisse estimated recently, before Tesla released full-year production figures.

Tesla leaned on in-house software-engineering expertise to keep production lines running last year, quickly rewriting the software necessary to integrate alternative chips into its vehicles, Mr. Musk has said. It also benefited from the supply-chain visibility and supplier relationships that came with being more vertically integrated than many auto makers.

Tesla hasn’t been immune to supply-chain problems, however. The company has run factories below capacity and, in February, briefly shut down its Fremont, Calif., plant because of parts shortages. It also delayed production of its all-electric pickup, dubbed the Cybertruck, and semitrailer truck. Mr. Musk has said those vehicles are now due to enter production at the end of this year and in 2023, respectively. He also said he planned to provide an updated product road map on the company’s next earnings call, expected in a few weeks.

Tesla delivered roughly 308,600 vehicles in the final three months of 2021, up from 180,667 a year earlier and 241,391 in the third quarter of 2021.

Model 3 sedans and Model Y compact sport-utility vehicles made up most of Tesla’s annual deliveries, more than doubling from a year earlier. The company reported delivering a combined 911,208 Model 3s and Model Ys last year. Deliveries of the company’s higher-end models, the Model S luxury sedan and Model X sport-utility vehicle, totaled roughly 24,964, Tesla said, down from roughly 57,000 in 2020. Tesla last year introduced a revamped version of its luxury sedan called the Model S Plaid in a bid to reignite demand.

Analysts expect those results to help Tesla achieve record full-year profit of around $5 billion on nearly $52 billion of revenue, according to FactSet.

The company in 2022 is aiming to leverage new factories in Germany and Texas to help meet its growth target.

“The exercise in gauging potential 2022 deliveries is one of gauging Tesla’s supply capability,” Credit Suisse analyst Dan Levy said in a recent note, forecasting that the company would put roughly 1.3 million vehicles in customer hands this year.