Tesla Inc. TSLA 1.39% is moving its headquarters to Austin, Texas, cementing Chief Executive Elon Musk’s commitment to the Lone Star State and adding to a handful of Silicon Valley companies that have relocated there.

Mr. Musk announced the move from Tesla’s Austin-area factory, which the company began building last year and where it held its annual shareholder meeting Thursday. He added that Tesla plans to expand its activities in California but that the company’s ability to scale up in the San Francisco Bay Area is limited.

“You go to our Fremont factory, it is jammed,” he said. “We’re like Spam in a can.”

Mr. Musk said last year that he had moved to Texas, where his rocket company, Space Exploration Technologies Corp., or SpaceX, has major operations. He previously likened California to a sports team that had grown complacent after a winning streak. Tesla is following in the footsteps of companies including Hewlett Packard Enterprise Co. —a descendant of what Bill Hewlett and Dave Packard started in a Palo Alto, Calif., garage—and Oracle Corp. , which moved their corporate headquarters to Texas earlier in the Covid-19 pandemic.

Tech companies were among the earliest to send employees home at the start of the pandemic, and a number of prominent players in the industry have allowed their employees to work remotely on a permanent basis. That shift has prompted many Silicon Valley employees and startup CEOs to relocate to other parts of the country for cheaper housing, less traffic and a better quality of living.