Investment titans from Larry Robbins to Henry Kravis owe thanks to the U.S. Supreme Court.

Firms including Robbins’s Glenview Capital Management, Kravis’s KKR & Co., Bain Capital and Steve Mandel’s Lone Pine Capital saw paper gains after the court upheld a key piece of President Barack Obama’s Affordable Care Act, sending the Standard & Poor’s 500 Health Care Sector Index higher. Glenview and KKR collectively gained more than $350 million.

Hospital operators HCA Holdings Inc., Tenet Healthcare Corp. and Community Health Systems Inc. all surged more than 8.8 percent at the close of trading in New York after the ruling, which will allow tax subsidies nationwide to help people afford health insurance on exchanges set up by the 2010 law. Health insurers also advanced on the decision.

“We’re back in business,” said Sheryl Skolnick, director of research at Mizuho Securities USA in New York, who recommends investors buy HCA and Tenet. Glenview, KKR, Bain, Lone Pine, David Tepper’s Appaloosa Management, John Paulson’s Paulson & Co. and Paul Singer’s Elliott Management own stakes in either or both, according to data compiled by Bloomberg.

Obamacare, as the law is known, has provided millions of paying customers for hospitals and health insurers, in part through the subsidies that were upheld. The new clients have helped fuel a multiyear rally for health-care stocks, and more consumers are expected to emerge in the coming years.

HCA, Tenet

Glenview, which oversees about $11.6 billion, was the biggest winner among private investment firms, gaining almost $250 million from its ownership of HCA, Tenet, Community Health Systems and others. KKR, the private equity firm with $99 billion under management, gained about $109 million on its ownership of Nashville, Tennessee-based HCA, which it took private in a $32 billion leveraged buyout in 2006. The increases are based on the firm’s latest reported holdings.

The largest for-profit hospital chain, HCA rose 8.8 percent at the close of trading. Tenet jumped 12 percent, while Community Health climbed 13 percent.

Stock gains at insurers were smaller, in part because subsidized customers comprise a small part of business at the biggest companies. Still, the firms will benefit as more people purchase coverage in the future. Health insurer stocks have also rallied sharply in recent days amid speculation about mergers and acquisitions in the industry.

Aetna Inc., the second-biggest U.S. health insurer, is nearing an acquisition of Humana Inc. and could reach a deal as early as this weekend, several people with knowledge of the discussions said Thursday. The people asked not to be named because the talks are private, and representatives for the companies declined to comment.