The U.S. stock market finished higher Tuesday, with the Dow logging its second straight record and a sixth straight session in positive territory on the back of upbeat earnings, shaking off less-than-stellar reports on manufacturing and inflation.

The Dow Jones Industrial Average DJIA, -0.87% added 72.80 points, or 0.3%, to finish at an all-time closing high at 21,963.92, marking its 31st record in 2017 and putting the blue-chip gauge within 40 points of a milestone at 22,000. The Dow had touched an intraday all-time high at 21,990.96 before retreating somewhat.

Read:Dow flirts with a fresh milestone — 22,000

The blue-chip benchmark has been steadily outperforming other benchmarks over the past few sessions, thanks in part to earnings-driven gains in aircraft maker Boeing Co. BA, -3.81% and oil giant Chevron Corp. CVX, -0.73% . On Tuesday, Intel Corp. INTC, -0.85% led the advance, rising 2.5%., as Boeing halted a win streak at seven sessions, closing down 1.3% on Tuesday.

The S&P 500 index SPX, -1.11% rose 6.05 points, or 0.2%, to 2,476.35, not far from its record close set last week at 2,477.83. Financials and technology were among the best sector performers of the S&P 500’s 11 industry groups.

The Nasdaq Composite Index COMP, -1.07% advanced 14.82 points, or 0.2%, to 6,362.94.

“A combination of [market] fundamentals and positive earnings are propelling stocks higher” amid a market-friendly backdrop as the Federal Reserve takes a gradual path to normalizing interest rates along with healthy global growth, said Quincy Krosby, chief market strategist at Prudential Financial.

Earnings remained in focus, with traders awaiting further signs of upbeat sentiment in earnings, which have so far provided healthy, said Craig Erlam, senior market analyst at Oanda.

As of last Friday, 73% of the S&P 500 companies that had reported earnings posted sales numbers above estimates, according to FactSet. That puts the second quarter on track to mark the highest percentage of companies beating sales forecasts since FactSet began tracking data in 2008.

Apple Inc. AAPL, -3.17% was slated to report after the closing bell. The iPhone maker’s results are likely to attract more than the usual share of scrutiny as the tech giant is the last of the so-called FAANG group of high-growth stocks comprised of Facebook Inc. FB, -0.89% , Apple, Amazon.com Inc. AMZN, -1.78% , Netflix Inc. NFLX, -0.05% , and Google -parent Alphabet Inc. GOOGL, -2.41% — to report. Apple’s stock rose slightly to $149.17.

Read:Apple earnings: How long will iPhone sales be on ‘pause’?

See also:The stock market’s fortunes may ride on Apple’s shoulders

Stock movers: Xerox Corp. XRX, -2.87% shares rallied 5.8% after better-than-expected earnings.

Shares of Ford Motors F, -0.68% dropped by 2.4% and General Motors Co. GM, -1.31% shares finished 3.4% lower after reporting sharp declines in car sales in July.

Archer Daniels Midland Co. ADM, -0.27% shares rose 2.7% after the company beat earnings estimates.

Steven Madden Ltd. SHOO, -1.94% also reported earnings that topped estimates, sending shares 2% higher.

Sprint Corp. US:S shares jumped 11.2% as the telecom company posted profit for the first time in three years.

Royal Caribbean Cruises Ltd. RCL, -4.80% shares jumped 3.4% after the company beat earnings estimates and raised its profit guidance.

Shares of Regeneron Pharmaceuticals Inc. REGN, -1.72% fell 4% after Baird downgraded the company to underperform.

Shares of Pfizer Inc. PFE, -0.51% slipped 0.2% after the drugmaker reported adjusted earnings ahead of forecasts.

Beyond tech giant Apple, after the market close, Herbalife Ltd. HLF, -2.16% , Allstate Corp. ALL, -1.63% and Match Group Inc. MTCH, +0.79% are among companies slated to report.

Political reversals: Investors were still assessing the latest drama from the White House, in which communications director Anthony Scaramucci on Monday was removed from his post after just 10 days in the job.

“The dismissal of the U.S. White House communications director could be interpreted as the reasserting of authority over the executive branch, or a signal of the worst chaos the White House has known since President Jackson’s inauguration,” said Paul Donovan, global chief economist at UBS, in a note.

Check out:Ex-Marine Kelly in, ex-Wall Streeter Scaramucci out: Why Trump made the switch

Economic news: Consumer spending in June rose by the smallest amount in five months as income growth flatlined, but lower gasoline prices also played a role.

The personal-consumption expenditure index, or PCE index, the Federal Reserve’s preferred inflation gauge, was flat in June. What’s more, the 12-month rate of inflation stood at 1.4%, down from 2.2% earlier in the year.

The IHS Markit final manufacturing PMI climbed to 53.3 in July from a preliminary result of 52.

The ISM manufacturing index fell to 56.3% in July from 57.8%, while construction spending slipped 1.3% from revised May reading to $1.21 trillion SAAR in June.

Other markets: European stocks SXXP, -0.66% traded higher, while Asian markets also gained.

The dollar DXY, +0.03% edged 0.2% higher following a recent selloff, while oil prices US:CLU7 settled 2% lower as investors fretted about the ability of major oil producers to trim a global glut of crude. Gold futures US:GCZ7 closed near an eight-week peak.

—Sara Sjolin and Mark DeCambre contributed to this article