By Karen Langley, Anna Hirtenstein and Frances Yoon

U.S. stocks rose Wednesday on optimism about the prospects for economic recovery in the wake of the coronavirus pandemic.

All 50 states have relaxed some of their coronavirus restrictions as officials seek to revive economies battered by the pandemic, and investors are continuing to focus on any sign of hope for a vaccine.

The S&P 500 gained 48.67 points, or 1.7%, to 2971.61, closing at its highest level since early March. The Dow Jones Industrial Average added 369.04 points, or 1.5%, to 24575.90, and the technology-heavy Nasdaq Composite rose 190.67 points, or 2.1%, to 9375.78.

The gains were broad, with all 11 sectors of the S&P 500 in the green. The beaten-down energy group was the biggest gainer, rising 3.8% as crude oil rallied.

The Russell 2000 index of small-capitalization companies, which tend to be sensitive to the domestic economy, gained 3%, outpacing the major large-cap indexes.

"If the economic reopenings are going well, or better than expected, on a consistent basis, the small caps will let us know," said Chris Hyzy, chief investment officer at Merrill and Bank of America Private Bank.

Stocks have rebounded sharply from their March lows, with the S&P 500 up 33% despite the blow the pandemic has dealt to the businesses and households and the uncertainty about the medical and economic path ahead.

"Valuations have accelerated quite quickly," said Kevin Walkush, portfolio manager at Jensen Investment Management. "Our expectation is as news flow becomes available, that's probably going to drive a high degree of volatility going forward."

Airline shares, which have been battered by the halt in global travel, popped, with United Airlines, Delta Air Lines and Southwest Airlines each up more than 4%. Airline executives have said bookings are picking up again, a potential inflection point for the industry.

Wednesday brought further news of potential progress in the race for a vaccine. Inovio Pharmaceuticals said its experimental coronavirus vaccine induced immune responses in mice and guinea pigs, according to a new study published in Nature Communications. Researchers from the biotechnology company and its academic collaborators said the data were encouraging but more testing is needed in animals and humans. Shares jumped $1.23, or 8.4%, to $15.79.

The Inovio news came two days after drugmaker Moderna said the first human study of its experimental coronavirus vaccine showed promise in some of the healthy volunteers who were vaccinated. That report helped send stocks surging Monday.

Many investors expect to continue seeing big market reactions as news trickles in about the success of business openings and the race to develop treatments and vaccines.

"What's key is how we open up this economy going into the fall and whether or not the opening of the U.S. economy induces a coronavirus surge," said Quincy Krosby, chief market strategist at Prudential Financial. "We remain at the mercy of the virus."

Investors carefully watching the Federal Reserve for signs of future monetary policy got their first opportunity Wednesday to parse the minutes of the central bank's April 28-29 policy meeting. Officials spent much of the meeting reviewing progress on lending programs to backstop everything from short-term funding markets to markets for corporate debt and municipal bonds.

The yield on the 10-year U.S. Treasury ticked down to 0.679% from 0.711% Tuesday. Bond yields fall as prices rise.

Meanwhile, the latest earnings reports from retailers continued to be a mixed bag. Home-improvement retailer Lowe's beat analysts' estimates with a higher quarterly profit as online sales grew during the pandemic. But the company withdrew its financial guidance for the year, citing an uncertain business outlook from the pandemic. Shares edged up 12 cents, or 0.1%, to $116.99.

Target said sales surged in the most recent quarter, but the retailer's per-share earnings fell by nearly two thirds from the same period last year. Shares fell $3.54, or 2.9%, to $119.63.

"There's a consensus around the fact that companies can adapt [to the pandemic], but at the expense of slightly higher costs," said Michael Hewson, chief market analyst at brokerage CMC Markets.

Overseas, the Stoxx Europe 600 index rose 1%. Japan's Nikkei 225 rose 0.8%, while the Shanghai Composite declined 0.5%.

Write to Karen Langley at karen.langley@wsj.com, Anna Hirtenstein at anna.hirtenstein@wsj.com and Frances Yoon at frances.yoon@wsj.com