U.S. stocks edged higher Tuesday, led by shares of consumer discretionary companies.

The S&P 500 rose 0.3% after wobbling earlier in the session. The Dow Jones Industrial Average and Nasdaq Composite added 0.2% and 0.3%, respectively, building on Monday’s rally.

Consumer discretionary stocks including L Brands and Etsy led the advance. Tech stocks aided the climb, with stocks including Nvidia notching solid gains in morning trading, along with shares of consumer staples, material firms and energy companies.

Still, markets remain volatile as stocks trade near records. Investors continue to look for clues about how quickly the Federal Reserve will move to pull back its support of the economy, with all eyes again turning to the central bank’s chairman, Jerome Powell.

Mr. Powell will testify before Congress Tuesday, detailing the central bank’s response to the pandemic. Prepared remarks released a day earlier suggest Mr. Powell will tell lawmakers that job growth should pick up in coming months and temporary inflation pressures should ease as the economy continues to recover from the effects of the pandemic.

He is likely to take questions on the outlook for inflation and the labor market, which may offer fresh insights into the potential pace of interest-rate increases and the easing of the Fed’s bond-buying program.

“The market is in a very fragile, emotional state,” said Altaf Kassam, head of investment strategy for State Street Global Advisors in Europe. “It will be a rocky road, it will be bumpy and pronouncements from central bankers are going to get very quick, knee-jerk responses.”

Money managers are reconciling themselves to the idea that stimulus measures will be pared back slowly, but not in the immediate future, he added. “There is still plenty of time for markets to get accustomed to [a rate increase]. It really doesn’t feel like the beginning of the end just yet.”

In bond markets, the yield on the 10-year U.S. Treasury note edged up to 1.483%, from 1.481% on Monday. Yields rise when bond prices fall. The 30-year yield, which has been particularly volatile in recent days, ticked up to 2.137% from 2.103% on Monday.

Within the stock market, consumer discretionary stocks in the S&P 500 rose 0.9%. L Brands, the index’s biggest gainer, added nearly 5%, while Etsy rose 3.8%. Tech stocks also factored into Tuesday’s advance, with Nvidia rising 2.2%.

Real-estate stocks continued to cling to minor declines.

Other individual gainers included GameStop, whose shares rose 6.4% after the videogame retailer said it had raised over $1 billion from the sale of shares. Meanwhile, Sanderson Farms added 10% after The Wall Street Journal reported that the company is exploring a sale, according to people familiar with the matter.

Overseas, the Stoxx Europe 600 index added 0.2%. Japan’s Nikkei 225 index jumped 3.1% by the close of trading. In China, the Shanghai Composite Index added 0.8%. Hong Kong’s Hang Seng Index edged down 0.6%.

The New York Stock Exchange on Monday.

The New York Stock Exchange on Monday.

Photo: brendan mcdermid/Reuters

Write to Will Horner at William.Horner@wsj.com and Michael Wursthorn at Michael.Wursthorn@wsj.com