By Caitlin Ostroff and Karen Langley

U.S. stocks rose Wednesday after White House negotiators said they aim to reach a deal on a new coronavirus-relief package by the end of the week.

In a sign of optimism about prospects for the economy, cyclical sectors -- such as industrials, materials and financials -- led the S&P 500, a departure from the technology group's outperformance this year.

The broad U.S. stock index gained 21.26 points, or 0.6%, to 3327.77, within 2% of its record close in late February, before fears tied to the pandemic began to pummel U.S. markets.

The Dow Jones Industrial Average advanced 373.05 points, or 1.4%, to 27201.52, boosted by a big gain in shares of Walt Disney. The tech-heavy Nasdaq Composite added 57.23 points, or 0.5%, to 10998.40, its 31st record close of 2020.

Investors have been watching for signs that the government will deploy more fiscal stimulus to help counter the economic damage caused by the pandemic. Many economists expect last week's expiration of $600 in enhanced weekly unemployment benefits to lead to a sharp drop in household spending.

Negotiators from the White House said Tuesday that they aim to reach agreement with Democrats on another aid package by week's end. Both sides have said they made progress in talks to bridge differences on unemployment payments and other proposals.

"You can't spend what you don't have," said Norm Conley, chief executive and chief investment officer at JAG Capital Management. "With as many people out of work as there are, that would have a negative impact on consumer spending if this deal, or some sort of deal, didn't materialize in the next week or two."

Economists have worried that a rise in U.S. coronavirus infection rates last month could curtail economic recovery as some regions moved to impose local restrictions to curb the number of cases. Wednesday's ADP National Employment Report showed nonfarm private-sector employment in the U.S. increased by 167,000 jobs in July, less than the 1 million increase economists expected.

In one sign of potential strength in the stock market, economically sensitive sectors such as industrials, materials and financials were the top-performing groups in the S&P 500. Over the course of the year, the technology sector has led the index.

"Having more stocks participate in the rally is encouraging for investors because it means that more parts of the economy are improving potentially," said Teresa Jacobsen, managing director at UBS Private Wealth Management.

As earnings season continued, shares of Walt Disney rose $10.32, or 8.8%, to $127.61 after the media and entertainment company reported strong subscriber growth for its streaming service. Shares of payments company Square gained $9.72, or 7.1%, to $146.55 after the company said usage of its Cash App and Cash Card increased as consumer spending picked up after the easing of lockdown measures.

Gold gained 1.5% to $2,031.10 a troy ounce, extending a bull run that has gained momentum during the coronavirus pandemic. This year's sharp drop in yields on U.S. Treasurys to levels below the expected pace of inflation is making gold, which doesn't generate an income, more attractive as a store of value. The precious metal, viewed as a haven asset, is also drawing investors concerned that the economic fallout from the pandemic may lead to another rout in stocks.

"It reminds me of the price rally in 2011 when gold posted its previous record," said Carsten Fritsch, an analyst at Commerzbank. He said gold could climb higher given guidance from the Federal Reserve that central bankers will keep interest rates low. "There's no hint of higher interest rates in the near future, even if there's an uptick in economic activity," he said.

Brent crude oil rose 1.7% to $45.17 a barrel. Optimism among investors, falling U.S. inventories and a weaker dollar have supported oil.

In bond markets, the yield on the 10-year U.S. Treasury ticked up to 0.541%, from 0.514% Tuesday, which was the second-lowest closing level this year.

Write to Caitlin Ostroff at caitlin.ostroff@wsj.com and Karen Langley at karen.langley@wsj.com