NEW YORK, May 8 (Reuters) - U.S. stocks erased earlier gains with the S&P 500 and the Nasdaq turning lower in a volatile session, led by losses in the energy and utility sectors.

A turnaround in beaten-down momentum names had boosted the Nasdaq earlier, while a drop in initial jobless claims suggested the labor market was improving and had helped lift the broader market.

But a late selloff in utilities and energy, among the best performing sectors recently, dragged the S&P 500 and the Nasdaq to near session lows.

“I think it was technical once again. We got right to resistance, we challenged it, but had no momentum to get through,” said Ken Polcari, director of the NYSE floor division at O‘Neil Securities in New York.

The S&P utility sector index was down 1.2 percent and the energy sector index was off 1.1 percent.

The Dow Jones industrial average rose 4.53 points or 0.03 percent, to close at 16,523.07, the S&P 500 lost 5.88 points or 0.31 percent, to 1,872.33 and the Nasdaq Composite dropped 23.751 points or 0.58 percent, to finish at 4,043.923.

Momentum stocks rebounded. The Global X Social Media Index ETF, which had fallen more than 14 percent since April 22, advanced 0.9 percent.

But Tesla Motors shares fell 11 percent to $178.74, a day after the company’s outlook for the second quarter that disappointed some investors.

Of 445 companies in the S&P 500 that have reported earnings through Wednesday morning, 68.2 percent beat expectations, above the 63 percent average since 1994 and the 66 percent beat rate for the past four quarters, according to Thomson Reuters data.

Profits are expected to rise 5.3 percent this quarter, down from the 6.5 percent estimated at the start of the year, but above the low of 0.6 percent in mid-April, according to Thomson Reuters data.

U.S. Federal Reserve Chair Janet Yellen, in testimony to a Senate panel, said no decision had yet been made on the central bank’s portfolio of assets, which has swollen to $4.5 trillion from about $800 billion in 2007. If the Fed ultimately shrinks it to a pre-crisis size, the process could take the better part of a decade, Yellen said.

Initial claims for state unemployment benefits declined 26,000 to a seasonally adjusted 319,000 for the week ended May 3, snapping three weeks of declines. Economists polled by Reuters had forecast first-time applications for jobless benefits to fall to 325,000 last week. (Additional reporting by Rodrigo Campos; Editing by Nick Zieminski)