For much of last year, established automakers like General Motors and Ford Motor operated in a different reality from Tesla, the electric car company.

G.M. and Ford closed one factory after another — sometimes for months on end — because of a shortage of computer chips, leaving dealer lots bare and sending car prices zooming. Yet Tesla racked up record sales quarter after quarter and ended the year having sold nearly twice as many vehicles as it did in 2020 unhindered by an industrywide crisis.

Tesla’s ability to conjure up critical components has a greater significance than one year’s car sales. It suggests that the company, and possibly other young electric car businesses, could threaten the dominance of giants like Volkswagen and G.M. sooner and more forcefully than most industry executives and policymakers realize. That would help the effort to reduce the emissions that are causing climate change by displacing more gasoline-powered cars sooner. But it could hurt the millions of workers, thousands of suppliers and numerous local and national governments that rely on traditional auto production for jobs, business and tax revenue.

Tesla and its enigmatic chief executive, Elon Musk, have said little about how the carmaker ran circles around the rest of the auto industry. Now it’s becoming clear that the company simply had a superior command of technology and its own supply chain. Tesla appeared to better forecast demand than businesses that produce many more cars than it does. Other automakers were surprised by how quickly the car market recovered from a steep drop early in the pandemic and had simply not ordered enough chips and parts fast enough.

When Tesla couldn’t get the chips it had counted on, it took the ones that were available and rewrote the software that operated them to suit its needs. Larger auto companies couldn’t do that because they relied on outside suppliers for much of their software and computing expertise. In many cases, automakers also relied on these suppliers to deal with chip manufacturers. When the crisis hit, the automakers lacked bargaining clout.

Just a few years ago, analysts saw Mr. Musk’s insistence on having Tesla do more things on its own as one of the main reasons the company was struggling to increase production. Now, his strategy appears to have been vindicated.

Cars are becoming increasingly digital, defined by their software as much as their engines and transmissions. It’s a reality that some old-line car companies increasingly acknowledge. Many, including Ford and Mercedes-Benz, have said in recent months that they are hiring engineers and programmers to design their own chips and write their own software.

“Tesla, born in Silicon Valley, never outsourced their software — they write their own code,” said Morris Cohen, a professor emeritus at the Wharton School of the University of Pennsylvania who specializes in manufacturing and logistics. “They rewrote the software so they could replace chips in short supply with chips not in short supply. The other carmakers were not able to do that.”

“Tesla controlled its destiny,” Professor Cohen added.

Tesla sold 936,000 cars globally in 2021, an 87 percent increase for the year. Ford, G.M. and Stellantis, the company formed from the merger of Fiat Chrysler and Peugeot, all sold fewer cars in 2021 than they did in 2020.

Measured by vehicles delivered globally, Tesla vaulted past Volvo and Subaru in 2021, and some analysts predicted that it could sell two million cars this year, as factories in Berlin and Austin, Texas, come online and a plant in Shanghai ramps up production. That would put Tesla in the same league as BMW and Mercedes — something few in the industry thought possible just a couple of years ago.

G.M. and Ford, of course, sell many more cars and trucks. Both companies said last week that they sold around two million vehicles last year just in the United States.

Tesla, which rarely answers questions from reporters, did not respond to a request for comment for this article. It has said little publicly about how it managed to soar in a down market.

“We have used alternative parts and programmed software to mitigate the challenges caused by these shortages,” the company said in its third-quarter earnings report.

The performance is a stark turnaround from 2018, when Tesla’s production and supply problems made it an industry laughingstock. Many of the manufacturing snafus stemmed from Mr. Musk’s insistence that the company make many parts itself.

Other car companies have realized that they need to do some of what Mr. Musk and Tesla have been doing all along and are in the process of taking control of their onboard computer systems.

Mercedes, for example, plans to use fewer specialized chips in coming models and more standardized semiconductors, and to write its own software, said Markus Schäfer, a member of the German carmaker’s management board who oversees procurement.