NEW YORK (Reuters) - Shares of U.S. hospital operators surged on Monday after Republicans’ pulled their healthcare bill, preserving for now the benefits that hospitals gained under Obamacare.

A trader looks at screens while working on the floor of the New York Stock Exchange (NYSE) in New York, U.S., March 27, 2017. REUTERS/Lucas Jackson

Shares of Medicaid-focused health insurers, such as Molina Healthcare MOH.N and Centene CNC.N, also jumped as the bill would have threatened the expansion of the Medicaid government health program for low-income Americans.

The stock increases for the two groups stood out on an otherwise dour day for the stock market, as investors fretted that President Donald Trump’s failure to push through the healthcare overhaul boded poorly for the rest of his economic agenda.

Shares of HCA Holdings HCA.N, by far the most valuable publicly-traded hospital company, climbed 5.4 percent, making it the best-performing stock in the benchmark S&P 500 .SPX on Monday.

Shares of Tenet Healthcare THC.N, Community Health Systems CYH.N and Universal Health Services UHS.N each rose at least 4 percent.

Republican leaders late on Friday afternoon pulled their legislation to overhaul the U.S. healthcare system, dealing a stunning setback to Trump.

A Republican-led repeal of the Affordable Care Act, known as Obamacare, would have threatened hospitals’ adjusted operating profit by between 5 percent to 10 percent, according to Oppenheimer & Co analyst Michael Wiederhorn.

“The hospital industry is the ultimate winner in this decision,” Wiederhorn said in a research note.

Mizuho Securities analysts raised their ratings on shares of HCA and Universal Health to “buy” from “neutral” in the wake of the Republican failure.

But the Mizuho analysts also noted: “Now we see fundamentals as mattering more to these shares - and industry inpatient volumes still aren’t good.”

The failure of the bill dealt a setback to short-sellers betting against hospital stocks. In particular, short interest stood recently at 21 percent of shares outstanding of both Tenet and Community Health, according to Thomson Reuters data.

Among insurer stocks, Centene rose 2.6 percent and Molina gained 4 percent.

Medicaid-focused insurers “will likely gain investor support as expansion does not go away, and may increase,” Stifel analyst Thomas Carroll said in a research note.

Shares of larger more diversified insurers drifted lower, with Anthem ANTM.N down 1.1 percent and Aetna AET.N off 1 percent.

Investors may have been disappointed that a tax on the insurance industry that would have disappeared with the Republican bill stood to affect the companies going forward.

“It will now be back in 2018 providing an earnings headwind that the market has largely assumed would not exist,” Carroll said.