Major U.S. stock indexes rose Tuesday as investors snapped up shares of companies across industries.

The S&P 500 advanced 0.4%, while the Dow Jones Industrial Average added 0.7%, or about 248 points. The tech-heavy Nasdaq Composite climbed 0.7%.

Seven of the S&P 500’s 11 sectors were recently up for the day, with the financials group gaining...

Major U.S. stock indexes rose Tuesday as investors snapped up shares of companies across industries.

The S&P 500 advanced 0.4%, while the Dow Jones Industrial Average added 0.7%, or about 248 points. The tech-heavy Nasdaq Composite climbed 0.7%.

Seven of the S&P 500’s 11 sectors were recently up for the day, with the financials group gaining 1% and the technology group rising 0.8%. The energy segment bucked the trend, declining 2.5% as oil prices fell.

The S&P 500 is still down 5.5% in 2022 after selling off in January.

“It just looks like people are very happy sort of buying the dip,” said Katie Nixon, chief investment officer at Northern Trust Wealth Management. “We have very strong markets across the board here.”

A generally positive earnings season has helped support stocks. With results in from about 60% of S&P 500 companies, analysts expect profits rose 30% in the fourth quarter from a year earlier, according to FactSet. That is up from estimates for 21% growth at the end of September.

At the same time, a number of companies have adopted a wary tone about the path ahead. As of late last week, 34 companies in the S&P 500 had given earnings guidance for the first quarter that was lower than analysts had been expecting, while 13 companies had issued guidance higher than the average earnings estimate, according to FactSet.

“The guidance we’re hearing from companies is understandably cautious,” said Tom Plumb, president and portfolio manager at Plumb Funds. “It’s feeding, in some cases, the anxiety people have about political and economic events and Federal Reserve policy.”

Markets have been roiled by volatile trading in recent sessions, prompted in part by expectations of higher interest rates. The Fed’s expected tightening comes against a backdrop of moderating growth and investors have been reassessing which companies are best-placed to weather the more challenging outlook.

“The question is: Does the Fed get it right? Do they walk the line properly between raising rates and tightening policy at a pace that helps to curb inflation but doesn’t slow demand and hurt the economy,” said Peter Langas, chief portfolio strategist at Bessemer Trust.

The Federal Reserve has signaled it plans to raise interest rates in 2022 in response to stubbornly high inflation. WSJ’s J.J. McCorvey explains what higher rates could mean for your finances. Photo illustration: Todd Johnson

Tech firms, the darlings of last year’s rally, have been at the forefront of investors’ reassessments, as higher interest rates threaten to weigh on their pricey valuations, which rely on expectations for growth far into the future. Large-cap tech firms have been particularly choppy in recent days, exacerbating broader market volatility.

Shares of Apple and Amazon.com each rose more than 1% on Tuesday, while shares of Facebook parent Meta Platforms

fell 3.4%. Meta shares plunged last week after the company surprised investors with a deeper-than-expected profit decline and a downbeat outlook.

“Across the tech spectrum, investors will be more discerning of the underlying fundamentals and long-term drivers of growth and strategy,” said Bessemer’s Mr. Langas. “Companies that are able to contend with threats in a strong way are going to be rewarded and those that are struggling are going to be penalized.”

Brent crude, the international oil benchmark, declined 2.1% to $90.78 a barrel. Investors were tracking talks over reviving a nuclear agreement with Iran, since a deal could see sanctions on that country lifted, allowing it to export more oil.

The pullback in oil prices contributed to a gloomy tone for energy stocks. Chevron shares dropped 2% and Exxon Mobil shares fell 2.7%.

Earnings reports drove some of Tuesday’s moves in individual stocks. Pfizer shares fell 3.7% after the vaccine maker reported revenue that missed analysts’ forecasts. Harley-Davidson shares rose 14% after the motorcycle maker swung to a fourth-quarter profit.

Peloton Interactive shares jumped 25% after the stationary-bike maker said it would replace its chief executive, overhaul its board and cut costs. The company, whose value has plummeted amid a slowdown in demand, will post earnings after markets close. 

Nvidia shares added 0.6% after the semiconductor giant said it was calling off its blockbuster deal to buy chip-design specialist Arm.

Investors edged out of bonds on the expectation that the Federal Reserve is poised to embark on a course of interest-rate increases. The yield on the benchmark 10-year U.S. Treasury note rose to 1.950%, putting it on course for its highest closing level since 2019, after settling at 1.915% Monday. Yields rise when prices fall.

Traders on the floor of the New York Stock Exchange on Monday.

Photo: Allie Joseph/Associated Press

Bitcoin recently traded at about $42,867, down 2.7% from its level at 5 p.m. ET Monday. Earlier Tuesday the cryptocurrency traded above $45,000 before paring its gains.

Overseas, the pan-continental Stoxx Europe 600 edged up less than 0.1%. Asian stock markets were mixed. Japan’s Nikkei 225 edged up 0.1%, while in Hong Kong, the Hang Seng Index fell 1%. In mainland China, the Shanghai Composite Index added 0.7%.

Write to Karen Langley at karen.langley@wsj.com and Will Horner at william.horner@wsj.com