AbbVie, Eli Lilly and Gilead Sciences closed near record highs Thursday, as a selloff in technology shares pushed investors toward pharmaceutical stocks seen as steadier bets. The three drugmakers finished the session at or close to their highest prices ever, according to MarketWatch.

The rally came as money flowed out of high-multiple technology names, which have led the market for most of the past two years. Investors rotating into health care are betting that drugmakers' revenue is less tied to the economic cycle and less vulnerable to the interest rate swings that hit growth stocks hardest.

Eli Lilly has been the standout of the group. The Indianapolis-based company's market value has climbed past $700 billion on demand for its weight-loss and diabetes drugs Zepbound and Mounjaro, making it the most valuable health care company in the world. Gilead Sciences, based in Foster City, California, has leaned on its HIV treatment franchise and cancer drug Trodelvy to keep revenue growing. AbbVie, the North Chicago maker of Humira and Skyrizi, has rebuilt sales momentum after Humira lost U.S. patent protection in 2023.

Health care is the second-best performing sector in the S&P 500 over the past month, trailing only utilities — another defensive corner of the market that tends to attract money when investors get nervous about tech valuations. The S&P 500 pharmaceuticals industry index is up more than 8% over that stretch.

The shift marks a reversal from earlier in the year, when drugmakers lagged the broader market on fears that Washington would force cuts to Medicare drug prices and that new tariffs on imported medicines would squeeze margins. Those concerns have eased in recent weeks, and analysts at several banks have raised price targets on large-cap pharma.

Pharmaceutical companies also offer something tech stocks largely do not: dividends. AbbVie pays a quarterly dividend of $1.64 per share, a yield of about 3.3%, while Gilead's payout of 79 cents a share yields roughly 2.8%. Eli Lilly, which pays a smaller dividend, has instead drawn buyers with earnings growth — the company reported a 36% jump in revenue in its most recent quarter.

Whether the rotation lasts depends largely on what technology earnings deliver in the coming weeks. A strong round of results from the largest tech companies could pull money back into the sector just as quickly, and pharmaceutical stocks would likely give back some of Thursday's gains.