The S&P 500 and Dow inched lower on Thursday as gains in Apple and Amazon were offset by weak energy and financial shares.

The Dow Jones Industrial Average fell 75 points, or 0.29%, to 25,509. The S&P 500 was in slightly positive territory most of the day but closed four points or 0.14% lower at 2,854. The Nasdaq Composite, however, bucked the trend to add three points, or 0.04%, to 7,892, nearing its all-time high.

The technology sector rose with shares of Apple rising 0.8% and those of Amazon adding 0.6%.

The S&P energy index led declines, with Occidental Petroleum falling 4.2% after it maintained a tepid production forecast for the year. The S&P financial index was down 0.6%.

Tesla declined 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%.

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

Rite Aid fell 11.5% after the drug store chain and US grocer Albertsons Cos agreed to terminate their merger agreement.

Yelp Inc. shares surged 27% after the review website late Wednesday reported better-than-expected earnings and raised its full-year profit outlook.

Viacom Inc. jumped 6% after reporting third-quarter earnings that beat expectations, but sales were below forecasts.

Chip stocks fell after Morgan Stanley downgraded the US semiconductor industry.

In the latest economic data, initial jobless claims fell more than expected in the latest week, while the July producer-price index was flat, compared with expectations for a 0.2% rise.

In Asia, shares were trading mixed on Friday in morning session, taking cues from Wall Street's overnight performance.

Japan's Nikkei 225 slipped 0.55%. In South Korea, the Kospi pulled back by 0.87%. Down Under, the S&P/ASX 200 erased earlier gains to inch lower by 0.18%.

In China, the Shanghai Composite Index fell 0.11%, while Hong Kong’s Hang Seng Index added 0.3%.