Five hundred companies make up Wall Street’s most widely used measure of the stock market’s performance: the Standard & Poor’s 500 index. If it were not for just six of them, the benchmark would be down this year.

That’s the bad news. The good news is that thanks to these six highflying stocks — including Apple, which on Wednesday became the first U.S. company to be valued at $2 trillion — the S&P 500 has powered through the coronavirus pandemic to gain almost 5 percent and set a record.

Along with Apple, the overachievers — Facebook, Amazon, Netflix, Microsoft and Google’s parent, Alphabet — are household names that have leveraged digital expertise to prosper amid the new, socially distanced reality. Through Tuesday, these six stocks collectively were up more than 43 percent this year, while the rest of the companies in the index together lost about 4 percent.

“These are sound companies that have been able to grow their earnings,” Ed Yardeni, a prominent investment strategist with Yardeni Research, said of the big tech stocks. “They’ve benefited from delivering goods and services in the pandemic. These are the companies at the very epicenter of booming demand.”

The market’s growing reliance on a handful of technology industry heavyweights, however, underscores a societal dominance that may be distorting investment signals, spawning a winner-take-all economy and warping political debates, critics have said. As the tech-dependent S&P 500 roared back from its pandemic crash earlier this year, these companies faced growing political opposition, including the threat of regulatory action in the United States and Europe aimed at curbing their influence.

“The regulatory environment next year is going to be brutal for these companies. It doesn’t make any difference who the [U.S.] president is,” said Roger McNamee, co-founder of Elevation Partners, a Silicon Valley private-equity firm. “The issues facing these tech companies are becoming more serious all the time. And the market may not be able to count on them.”

The outsize role played by these digital stars also creates risks for individuals trying to save for retirement. Investors have more than $1.1 trillion in mutual funds designed to mimic the S&P 500′s performance. With the stocks Yardeni dubs “the Magnificent Six” accounting for more than one-quarter of the index’s value, investors who think they are buying a diversified slice of the broad U.S. stock market are actually making a concentrated bet on companies that share many attributes, analysts said.

“It’s a big headache for investors,” Yardeni said.

But with most other stocks struggling amid the pandemic’s economic wreckage, investors are left with little choice. Amid the stop-and-start nature of some states’ reopenings and signs that the economic recovery may be plateauing, these companies have posted the most reliable business results.

On July 30, Amazon reported profit of $5.2 billion in its most recent quarter, topping analysts’ expectations, as online grocery sales tripled from the same period in 2019. The company’s shares have gained more than 70 percent this year. (Amazon chief executive Jeff Bezos owns The Washington Post.)

Likewise, Netflix last month said its earnings had ballooned to $720 million, up 165 percent from the same period in 2019. And Facebook, which has seen its shares rise by more 25 percent, reported its quarterly profit had nearly doubled to $5.2 billion.

“The dependence on such a small number of megacap stocks is not a healthy sign for the markets or the economy at large,” said Michael Farr, chief executive of the investment firm Farr, Miller and Washington. “It’s hard to determine what will knock the halos off these companies’ heads. My best guess is that it will take a more definitive improvement in the economic growth outlook or rising interest rates.”

This new two-track market was highlighted Wednesday when Apple briefly became the first stock to be valued at $2 trillion, before closing just below that mark as the market dipped. Since 2017, the Silicon Valley giant has rolled out a succession of new iPhones, braved President Trump’s trade wars, and navigated a global pandemic, while more than tripling its market value.

The president repeatedly has claimed the market comeback as evidence that the economy is roaring back. The swift rebound, marking the shortest bear market on record, surprised most prognosticators and represents a win for a White House thirsting for achievements to celebrate. That just a handful of stocks account for the market’s rebirth, however, calls into question its durability.

Still, the six companies’ success reflects their global footprint as well as a modern economy that is rapidly growing more technology-centric.

Although companies like Facebook, Google, Microsoft and Netflix are considered quintessential American success stories, each derives a greater percentage of its revenue from overseas operations than does the typical S&P 500 company, according to Barry Ritholtz, a New York investment manager. Only Amazon relies on North America for a disproportionately large share of its total sales.

To the extent that the handling of the pandemic and subsequent economic recovery has been better in Europe and parts of Asia, these companies’ cross-border setups have positioned them to flourish, he said.

Meanwhile, even as the U.S. economy suffered its worst contraction since records were kept, demand for these companies’ goods and services remained robust. Americans trapped at home by pandemic-related shutdowns shopped online, binged on movies and TV shows, reached out to friends on social media and used videoconferencing software to stay in touch with work colleagues.

All that tech-enabled activity showed up in the government’s economic report card.

In the second quarter, U.S. spending on information technology equipment, software and research and development topped $1.3 trillion, reaching a record 50 percent of total capital spending, according to the Commerce Department.

And while the big six stocks are generally described as technology companies, that’s really only half true. Facebook is a communications tool. Amazon is one of the nation’s largest retailers. Netflix is in the content creation and entertainment business.

“The lines are blurred because technology touches every sector,” said Liz Young, director of market strategy for BNY Mellon Investment Management.

The stocks are far from cheap, trading at a price-to-future-earnings ratio above 40. To some investors, continued investor demand for such high-priced stocks is itself a worrying sign. Buying them at current valuations amounts to making “an extremely bearish” bet on prospects for the rest of the economy, according to Richard Bernstein, a New York-based investment manager.

“You’re basically saying, ‘No other stock will grow,’ ” he said.

With a combined market value exceeding $7 trillion, these six companies account for more than one-quarter of the entire S&P 500. That explains how so few companies can lift an index of 500 stocks. Since the S&P 500 is weighted by each stock’s value, or market capitalization, gains by these larger companies have a greater effect than gains by an equal number of less valuable companies.

Still, such heady figures don’t mean that today’s small number of soaring stocks is destined to repeat the boom-and-bust cycle of the late 1990s Internet bubble, when investors swooned for any company that added dot-com to its name, Young said.

Still, she said, it would not be surprising if these stocks pulled back a bit, especially if a coronavirus vaccine seems imminent and people return to their pre-pandemic lifestyles.

McNamee, an early investor in companies such as Facebook and Amazon, warned that the six stocks that have driven the market to new highs face a reckoning. While the pandemic has spurred demand for their products, it also has provided fresh ammunition for their critics.

The use of platforms such as Facebook and Twitter to spread misinformation about the coronavirus and to fan racial intolerance, in particular, has opened the companies to attack, he said.

Last month, the CEOs of Apple, Amazon, Facebook and Google were lambasted by Democrats and Republicans at a House antitrust subcommittee hearing. Lawmakers charged that the companies have grown too large and powerful, gather too much data on individual consumers and censor political speech.

“The fact that tech stocks have dominated the market shouldn’t surprise anyone. That’s not a shock,” McNamee said. “But looking forward from here, tech stocks and the market face a very uncertain future.”

correction

This story has been corrected to reflect the fact that Apple is the first U.S. company to top $2 trillion in market value.