Facebook Inc, down 3.92%, was the biggest drag on the S&P 500 and Nasdaq, after the company warned that Apple Inc's new privacy changes would weigh on its digital business. Shares of the social media company closed below its 200-day moving average for the first time since March 8, a technical support level that could indicate further declines.

"Facebook has other issues, certainly the earnings report wasn't as stellar," said Ken Polcari, managing partner at Kace Capital Advisors in Boca Raton, Florida.

"Then pile on the issues with the whistleblower, what they knew, what they didn't know, how they set themselves up to benefit themselves even at the risk of kids and people that use the platform. That is going to kind of hang over it."

However, the benchmark S&P index scored a new high, lifted by names with big market capitalizations. Nvidia Corp gained 6.70% to close at a record high of $247.17, while Amazon.com Inc advanced 1.68% and Apple rose 0.46%.

Support also came from a 6.95% advance in United Parcel Service Inc and a 2.03% rise in General Electric Co on the heels of their quarterly results.

The Dow Jones Industrial Average rose 15.73 points, or 0.04%, to 35,756.88; the S&P 500 gained 8.31 points, or 0.18%, at 4,574.79; and the Nasdaq Composite added 9.01 points, or 0.06%, at 15,235.72.

Earnings at S&P 500 companies are expected to grow 35.6% year-on-year in the third quarter, with market participants gauging how companies are navigating supply-chain bottlenecks, labor shortages and inflationary pressures.

"(The market) is getting tired. They ran them up ahead of earnings because everyone is expecting them to be good and robust, and they are ... but the market feels tired to me now way up here," said Polcari.

While nearly all 11 S&P sectors rose on the session, defensive plays such as utilities and real estate were among the best performers, indicating some caution in the market.

After the closing bell, Microsoft Corp gained 1.29% while Google parent Alphabet Inc slipped 0.24% following their quarterly results.

Data showed U.S. consumer confidence unexpectedly rebounded in October as concerns about high inflation were offset by improving labor market prospects. A Commerce Department report showed sales of new single-family homes surged 14.0% in September.

Ross Mayfield, investment strategist at Baird in Louisville, Kentucky, said with indexes at or near record levels, a run of good economic data could increase investor concerns the Federal Reserve may pull its timeline for a rate hike forward.

The central bank's next policy announcement is expected on Nov. 3 after a two-day meeting.

Shares of Hasbro Inc climbed 3.23% after the toy maker posted an upbeat third-quarter profit even as it warned of a hit to holiday sales from supply chain issues.

Declining issues outnumbered advancers on the NYSE by a 1.13-to-1 ratio; on Nasdaq, a 1.23-to-1 ratio favored decliners.

The S&P 500 posted 69 new 52-week highs and no new lows; the Nasdaq Composite recorded 144 new highs and 79 new lows.

Volume on U.S. exchanges was 12.34 billion shares, compared with the 10.41 billion average for the full session over the last 20 trading days.

(Reporting by Chuck Mikolajczak; Editing by Richard Chang)

By Chuck Mikolajczak