NEW YORK (Reuters) - Healthcare company shares have taken the lead in the record-setting U.S. stock market, and a desire for investors to become more defensive combined with potentially strong upcoming earnings could drive them even higher.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., September 20, 2018. REUTERS/Brendan McDermid

One big uncertainty that threatens the sector’s run: the looming congressional elections in less than six weeks.

Healthcare .SPXHC has topped all other major S&P 500 sectors in the third quarter, rising more than 13 percent, or nearly twice the gain of the overall market in the period.

The surge has propelled healthcare into the top echelon of sector performers for the year, trailing only tech .SLPRCT and consumer discretionary .SPLRCD, both of which are undergoing a major shake-up that could cause confusion for investors who make broad sector bets and lead to even more investment in healthcare.

“In sector reallocation, momentum certainly plays a role, and we are still very early in the momentum of the healthcare sector,” said David Lafferty, chief market strategist at Natixis Investment Managers.

Investors took advantage of particularly cheap valuations for healthcare shares this summer. They were further attracted by the many healthcare companies that surpassed expectations for second-quarter profit and revenue, making it one of the best sectors on those measures.

With fears that the economy may be on the verge of slowing, investors said healthcare, which represents 15 percent of the S&P 500, has also benefited as a potential defensive play and relative safe haven in rocky market times.

“Healthcare really is giving investors a lot of bang for its buck right now,” said Martin Jarzebowski, healthcare sector head at Federated Investors.

As much as any sector, healthcare has a lot on the line with the upcoming Nov. 6 congressional elections. Investor worries about onerous regulations, particularly for prescription drug pricing, have abated recently, analysts said, allowing for a longtime policy cloud over the stocks to lift, even as U.S. President Donald Trump has sought to lower the cost of medicines for consumers.

Those fears would reemerge if expectations increase that Democrats were on track to seize control of both the Republican-held Senate and House of Representatives, as they are seen as more likely to impose tougher rules on industry.

“The biggest risk to the sector would be a Democratic sweep,” Jarzebowski said.

Following seven months of outflows, more than $4.6 billion has flowed into U.S.-based healthcare mutual and exchange traded funds since May, according to data from Lipper.

May is also when valuations for the sector reached their lowest point in more than a year, at 14.6 times forward earnings estimates, according to Thomson Reuters Datastream.

With its surge since then, healthcare now trades at 16.3 times earnings estimates for the next 12 months. That still makes it a bargain compared to the overall S&P 500, which trades at 16.9 times.

DEFENSIVE BET

Healthcare stocks could further benefit if investors become more wary of the economic outlook.

The sector has traditionally been viewed as having “defensive” characteristics, strategists said. Those include the need for medical services even in an uncertain economy, healthcare’s relatively lower volatility compared to other stock sectors and that many of the companies in the group have strong balance sheets.

“The later we get in the cycle, our enthusiasm for healthcare has only picked up,” Lafferty said.

For the third quarter, for which reports will start arriving next month, healthcare earnings growth is expected to slow to 10.8 percent from 16.2 percent and 18.3 percent in the first and second quarters, according to Thomson Reuters I/B/E/S.

Pharmaceutical companies, the biggest industry within the sector, are expected to see profit growth decline to 5.7 percent and 5 percent in the third and fourth quarters, respectively, from 12.1 percent and 19.8 percent in the first and second quarters, according to S&P Capital IQ.

That pullback in growth is one reason Lindsey Bell, investment strategist at CFRA Research, rates the sector as “market weight.”

“I think it’s a sector that will probably start to slow down,” Bell said.

Steven DeSanctis, an equity strategist at Jefferies, also said the sector “needs a pause” given its recent run.

“The thing that is going to keep this group moving ... is going to be very good earnings,” DeSanctis said.