NEW YORK — U.S. stocks rose across the board Wednesday following big gains in Asia and Europe, a buoyant end to the worst quarter for the market in four years.

From worries over a slowing Chinese economy, uncertainty over interest rates and a scary slide in commodity prices, stocks have been hit with one blow after another in the past three months. But on Wednesday, investors were in the mood to buy, especially stocks that have been battered recently. Energy companies and raw material suppliers, the biggest losers in the quarter, rose more than 2 percent each.

The buying began at the opening of trading and swept across all 10 sectors of the Standard and Poor’s 500 index. Among the big gainers, fashion company Ralph Lauren jumped 14 percent after announcing a new CEO would take over from its namesake founder.

Tim Courtney, chief investment officer of Exencial Wealth Advisors, said it was only a matter of time before investors started buying given the recent drops.

“I’ve been surprised we haven’t had rallies like the one we’re seeing now,” Courtney said. After “so many negative days, you’re going to get a bounceback.”

The S&P 500 jumped 35.94 points, or 1.9 percent, to 1,920.03. The index has fallen seven of the past 10 days, and is off 6.9 percent in the July-September period, the worst quarterly performance since 2011.

The Dow Jones industrial average gained 235.57 points, or 1.5 percent, to 16,284.70. It fell 7.6 percent in the quarter. The Nasdaq composite climbed 102.84 points, or 2.3 percent, to 4,620.16.

The rally in the U.S. followed even bigger gains overseas. Stocks indexes in France, Germany, Britain and Japan all climbed more than 2 percent.

The rocky third quarter began with fears over Greece’s debt, then moved on to worries about a rout in Chinese stocks, signs of slowing growth in the country and plunging currencies in developing countries that export to it. The S&P 500 dropped more than 10 percent in August from his May high, a drop known on Wall Street as a “correction.”

“It’s been ugly,” said John Canally, an investment strategist at LPL Financial. “We hadn’t had a 10 percent pullback since 2011, and people forget how to act.”

All five of the biggest drops in the year for the S&P 500 occurred in the last three months. Investors were so jumpy, they even sold on news that previously would have triggered buying. When the Federal Reserve announced earlier this month that it would hold off raising interest rates, the S&P 500 slipped.

On Wednesday, investors mustered enough courage to buy even biotechnology companies, breaking an eight-day streak of drops for the battered sector. The Nasdaq Biotechnology index, down 24 percent from a peak in July, rose 4.5 percent. It fell sharply last week after Democratic presidential front-runner Hillary Clinton tweeted that drug prices were too high, then said she would use government drug-buying programs to slash prices if elected.

Among stocks making big moves on Wednesday, Western Digital surged $10.57, or 15 percent, to $79.44 after the digital storage company agreed to a $3.8 billion investment from China’s Unisplendour.

The Gap fell $1.72, or nearly 6 percent, to $28.50. The new CEO of Ralph Lauren, Stefan Larsson, will leave his current job as global president of San Francisco-based Gap’s low-price Old Navy chain. Ralph Lauren rose $14.11 to $118.16.

Chesapeake Energy rose 54 cents, or 8 percent, to $7.33 after announcing that it would cut 15 percent of its workforce.

Investors are waiting for jobs data due out on Friday for clues about when the Federal Reserve may raise interest rates. Policymakers have said they will likely raise rates before the end of the year. On Wednesday, U.S. payroll processor ADP reported that U.S. employers added 200,000 jobs this month, up from 180,000 the previous month.

The price of oil fell slightly as total U.S. crude inventories rose. U.S. crude fell 14 cents to close at $45.09 a barrel in New York. Oil finished the volatile month down 8 percent.

Brent Crude, a benchmark for international oils used by many U.S. refineries, rose 14 cents to close at $48.37 a barrel in London.

More in News

SAN JOSE -- Grenades were discovered at an estate sale Monday, prompting the evacuation of about 10 homes near the San Jose Country Club, according to the Santa Clara County Sheriff's Office. Deputies were called to the 300 block of Gordon Avenue, near Greenside Drive, about 4:10 p.m., said Sgt. Rich Glennon. Get breaking news with our free mobile app....