NEW YORK (Reuters) - The S&P 500 and Dow ended down slightly on Thursday as gains in Apple AAPL.O and Amazon AMZN.O were offset by losses in energy and financial shares.

Tesla Inc's TSLA.O shares also fell to a two-day low and wiped out all of the gains fueled by Chief Executive Elon Musk's recent tweet announcing a plan to take the company private. The stock ended down 4.8 percent.

The S&P 500 was in slightly positive territory most of the day, putting it once again close to the record high it hit Jan. 26. The Nasdaq also neared its all-time high.

The technology sector has been at the center of a sharp recovery in U.S. stocks since a market rout in February.

Shares of Apple rose 0.8 percent, while those of Amazon AMZN.O were up 0.6 percent.

“It’s hard pressed for this market to really leap ahead. It’s been a slow, steady climb, led by an increasingly smaller number of companies,” said Rick Meckler, partner at Cherry Lane Investments, a family investment office in New Vernon, New Jersey.

“Somehow, technology seems a little more insulated” to concerns facing some companies, including trade war tensions, Meckler added.

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

Leading sector declines was the S&P energy index .SPNY, which fell 0.9 percent. Occidental Petroleum OXY.N fell 4.2 percent after it maintained a tepid production forecast for the year. The S&P financial index .SPSY was down 0.6 percent.

The Dow Jones Industrial Average .DJI fell 74.52 points, or 0.29 percent, to 25,509.23, the S&P 500 .SPX lost 4.12 points, or 0.14 percent, to 2,853.58 and the Nasdaq Composite .IXIC added 3.46 points, or 0.04 percent, to 7,891.78.

The biggest drag on the S&P 500 was Booking Holdings BKNG.O, which fell 5 percent after it forecast third-quarter profit below expectations.

Rite Aid RAD.N fell 11.5 percent after the drug store chain and U.S. grocer Albertsons Cos ABS.N agreed to terminate their merger agreement.

Chip stocks fell after Morgan Stanley downgraded the U.S. semiconductor industry.

The latest data pointed to strength in the labor market, underscoring the health of the U.S. economy despite ongoing trade tensions.

The number of Americans filing for unemployment benefits unexpectedly fell last week, a Labor Department report showed.

Declining issues outnumbered advancing ones on the NYSE by a 1.04-to-1 ratio; on Nasdaq, a 1.10-to-1 ratio favored advancers.

The S&P 500 posted 26 new 52-week highs and three new lows; the Nasdaq Composite recorded 97 new highs and 68 new lows.

About 5.9 billion shares changed hands on U.S. exchanges. That compares with the 6.3 billion daily average for the past 20 trading days, according to Thomson Reuters data.