Tech companies once powered New York’s economy. Now they are backing off.

For most of the past two decades, including during the pandemic, tech companies have been a bright spot in New York’s economy, adding thousands of high-paying jobs and expanding into millions of square feet of office space.

Their growth boosted tax revenue, made New York a credible competitor to the San Francisco Bay Area—and provided jobs that helped the city to accommodate Layoffs in other sectors during the pandemic and the 2008 financial crisis.

Now, the tech industry is in decline, clouding the economic future of the city.

Facing several business challenges, big tech companies have laid off more than 386,000 workers nationwide since early 2022, according to Layoffs, which tracks the tech industry. And they’ve taken down millions of square feet of office space due to job cuts and the transition to working from home.

The cut has hurt many technology centers, and San Francisco has been hardest hit with an office vacancy rate of 25.6 percent, according to Newmark Research.

New York is doing better than San Francisco — Manhattan has a vacancy rate of 13.5 percent — but it can no longer count on the tech industry for growth. According to Newmark, more than a third of the roughly 22 million square feet of office space available for sublease in Manhattan comes from technology, advertising and media companies.

Think Meta, which owns Facebook and Instagram. It is now offloading much of the more than 2.2 million square feet of office space it has gobbled up in Manhattan in recent years after laying off about 1,700 employees this year, or a quarter of New York state’s work force. The company elected not to renew leases covering 250,000 square feet at Hudson Yards and 200,000 square feet at Park Avenue South.

Spotify is trying to lease five of the 16 floors it leased six years ago at 4 World Trade Center, and Roku is offering a quarter of the 240,000 square feet it acquired in Times Square just last year. Twitter, Microsoft, and other tech companies are also trying to sublease unwanted space.

“Technology companies have been a huge part of the real estate landscape for the past five years,” said Ruth Kolb-Haber, CEO of Wharton Property Advisors, a real estate brokerage. “Now that they’re starting to cut back, the question is: Who’s going to replace them?”

Ms. Culp-Happer said it could take months for larger areas or entire floors of buildings to be sublet. The large amount of space available for subletting also leads to lower rents that landlords can obtain through new lease agreements.

“They’re going to cut every owner’s price in terms of prices, and they’ve got really nice spaces all built,” she said, referring to the technology companies.

The technology sector has been an engine of New York’s economy since the Internet boom of the late 1990s helped create “Silicon Alley” south of downtown. Then, after the financial crisis, the expansion of companies like Google fueled the economy when banks, insurance companies, and other financial companies were in decline.

Small and large technology companies added 43,430 New York jobs in the five years through the end of 2021, up 33 percent, according to the state comptroller. And those jobs paid well: The average tech salary in 2021 was $228,620, nearly double the average private-sector salary in the city, according to the Comptroller.

Growth in jobs has fueled demand for commercial space, and technology, advertising and media companies accounted for nearly a quarter of new office leases signed in Manhattan in recent years, according to Newmark.

Microsoft and Spotify declined to comment on their decision to sublease the space. Twitter and Roku did not respond to requests for comment. Meta said in a statement that it is “committed to distributed work” and is “constantly improving” its approach.

Still, few big tech companies are expanding in New York.

Google plans to open St. John’s Terminal, a large office near the Hudson River in Lower Manhattan, early next year. Including Terminal, Google will own or lease about seven million square feet of office space in New York, up from about six million feet today, according to a company representative. (Google leases more than 1 million square feet of that space to other tenants.) The company has more than 12,000 employees in the New York area, up from more than 10,000 in 2019.

And Amazon, which in 2019 canceled plans to build a large campus in Queens after local politicians objected to incentives for the company, has added 200,000 square feet of office space in New York, Jersey City and Newark since 2019. The company will add nearly 550,000 square feet of office space later this summer, when it opens 424 Fifth Avenue, the former Lord & Taylor store, which it bought in 2019. 020 for $1.15 billion.

“New York offers an incredible and diverse pool of talent, and we are proud of the thousands of jobs we have created in the city and state over the past 10 years across our corporate functions and operations,” Holly Sullivan, Amazon’s vice president of global economic development, said in a statement.

And while many tech companies continue to allow employees to work from home for much of the week, they’re also trying to lure workers back into the office, which could help reduce the need to sublease space.

Salesforce, a software company with offices in a tower next to Bryant Park, said it is not considering leasing its space in New York.

“I’m currently having the opposite problem with my tower in New York,” said Relena Bolchandani, Salesforce’s head of real estate. “There has been a concerted effort to continue to grow suitable roles in New York because we have a very high client base in New York.”

Industry representatives said that New York has been and will continue to be a vibrant home for technology companies.

“I haven’t heard of a single tech company leaving, and that’s significant,” said Julie Samuels, president of TECH: NYC, an industry association. “If anything, we’re seeing less contraction in New York among technology leases than we’re seeing in other big cities.”

Fred Wilson, a partner at Union Square Ventures, said tech executives now feel the need to be in Silicon Valley, a shift he said has benefited New York. “We have more corporate CEOs today and more founders in New York than we did before the pandemic,” said Mr. Wilson, referring to the companies his firm has invested in.

“We’re now working on several transactions with smaller, younger tech companies looking to acquire subcontract space,” said David Falk, Newmark’s Newmark tri-region president.

However, many companies are still holding back.

In 2017 and 2019, Stockholm-based Spotify signed leases totaling more than 564,000 square feet at 4 World Trade Center, becoming one of the largest tenants there. Soon she had a space with all the accessories you’d expect in a tech company — brightly colored flexible work areas, eye-popping views and ping-pong tables.

But in January, Spotify said it would lay off 600 people, or about 6 percent of its global workforce. The company, which allows employees to choose between working completely remotely or on a hybrid schedule, is also reducing its office space, putting five floors up for sublease.

“On days when I’m alone, I end up sitting in a conference room all day to focus on time,” said Dayna Tran, a Spotify employee who regularly works in the downtown office, adding that employees who come in motivate themselves and create community by collaborating on an office playlist.