A swift rise in government-bond yields is hitting shares of technology stalwarts that have powered major indexes higher for years, testing investors’ faith in some of the stock market’s most popular trades.

Shares of software giant Microsoft Corp., Google parent Alphabet Inc. and chip maker Nvidia Corp. have fallen about 4.5% or more so far this week, dragging down major indexes and equity funds that give companies with large market values greater influence. Together with Apple Inc., Amazon.com Inc., Facebook Inc. and Netflix...

A swift rise in government-bond yields is hitting shares of technology stalwarts that have powered major indexes higher for years, testing investors’ faith in some of the stock market’s most popular trades.

Shares of software giant Microsoft Corp. , Google parent Alphabet Inc. and chip maker Nvidia Corp. have fallen about 4.5% or more so far this week, dragging down major indexes and equity funds that give companies with large market values greater influence. Together with Apple Inc., Amazon.com Inc. , Facebook Inc. and Netflix Inc. , the seven companies lost about $315 billion in market value Tuesday, the largest slide since last October, according to Dow Jones Market Data. The S&P 500 is now down 3.8% in September and on track for its largest monthly decline in a year. 

The recent reversal comes with long-term Treasury yields surging at their fastest pace in months, lifting the yield on the benchmark 10-year U.S. Treasury note above 1.5%. Yields rise as bond prices fall and ripple through everything from mortgage rates to auto loans. The 10-year yield is at a three-month high, dimming some of the allure of tech companies. 

Low yields make many investors willing to pay more for shares of large tech companies that they expect to churn out outsize profits in the future. Yields tend to rise when investors feel better about the economy, so their advance tends to boost shares of companies that earn more money and increase shareholder returns during periods of global growth. So-called cyclical stocks are also cheaper. 

Investors pulled $1.2 billion out of tech mutual and exchange-traded funds during the week ended Sept. 22, the first such outflow in about three months, Bank of America figures from data provider EPFR Global show. A nearly $29 billion outflow from U.S. stock funds that week was the largest in more than 3½ years, halting a stretch of consistent inflows.   

While similar moves in yields and tech stocks in recent months have proven temporary, the latest swings come with many investors skittish about the prospect of rising interest rates. Recent bets on improving economic data and climbing inflation come after the Federal Reserve signaled it could start paring back bond purchases in November and lift rates in 2022. Some analysts say shifts in the economy caused by the coronavirus and supply-chain disruptions could further boost inflation and interest rates. 

The latest climb in yields upended wagers that they would stay low and that market values of tech leaders would continue swelling. Investors favored economically sensitive stocks as bond yields rose early in the year, then poured tens of billions of dollars into tech funds this summer as the so-called reopening trade faded. Those who crowded into tech stocks recently are now being forced to reassess those bets, analysts said. 

“A lot of them have not wanted to retreat from their positioning,” said Shawn Snyder, head of investment strategy at Citi U.S. Consumer Wealth Management. For tech stocks, he said, “the valuations remain elevated and they remain at risk when yields take these sharp jumps up.” He has recommended clients favor cheaper sectors such as healthcare, but still expects tech companies to continue growing steadily.

Many investors were already bracing for a pullback this fall after a monthslong run-up in stocks. The S&P 500 hasn’t traded 5% below an all-time high in nearly a year, the longest such streak since February 2018, according to Dow Jones Market Data. 

The market’s recent retreat comes with investors also worried about the impending collapse of Chinese property developer China Evergrande Group and a looming deadline for the U.S. government to reach a deal to raise the federal borrowing limit, or debt ceiling.

Gains in shares of Amazon.com and other internet companies have powered major indexes higher for years, but investors warn that declines in those popular stocks can also have an outsize impact on markets.

Photo: PHOTO: Tom Williams/Zuma Press

Sharp shifts like those seen recently are concerning for market watchers because downward momentum can feed on itself, making selloffs more severe. Many tech stocks have benefited from an explosion of trading in options, which allow the holder to buy or sell an asset at a specific price in the future. Market makers who sell options to investors often hedge their positions by buying the underlying shares, a force that can amplify share-price gains. 

But when stocks fall, those same trends can reinforce selling. Rising volatility and outflows from stock funds can also trigger selling by trend-following investors. Traders often use borrowed money to juice returns. When stocks and bonds fall in tandem like they have been, liquidating those trades can prompt others to also get out of their positions. 

Signs of such systematic selling are worrisome for investors because they can punish strong companies as much as weak ones.

“Everything gets thrown out, so that’s why we’re seeing some of the declines in tech across the board,” said Leslie Thompson, managing member at Spectrum Management Group. She continues to favor large tech companies such as Microsoft and Alphabet and said there are few attractive alternatives to holding stocks despite the recent rise in bond yields. 

Because companies worth trillions of dollars such as Microsoft, Alphabet, Apple and Amazon make up a sizable chunk of major indexes, big drops in those shares can have an outsize impact on the stock market. Even though energy stocks are up 3.9% this week and financial stocks are roughly flat, the S&P 500 is down 2.3%.

While many investors remain confident strong earnings will support stocks, more sudden rate swings could drive continued volatility, investors say. That is especially the case with the Delta variant of the coronavirus muddying recent economic data. 

“There’s a lot of caution about exactly where things go from here,” said Mr. Snyder of Citi U.S. Consumer Wealth Management.

Write to Amrith Ramkumar at amrith.ramkumar@wsj.com