NEW YORK - Stocks rose from the opening Wednesday, led by gains for the energy sector, as oil prices showed signs of stabilizing after their big slump in recent months. The market's gains were extended after Federal Reserve policymakers pledged to remain "patient" when deciding when to lift interest rates.

The Standard & Poor's 500 index rose 40.15 points, or 2.04 percent, to 2,012.89. That was the biggest gain for the index since October 2013.

The Dow Jones industrial average rose 288 points, or 1.69 percent, to 17,356.87. The Nasdaq composite climbed 96.48 points, or 2.12 percent, to 4,644.31.

Stock investors have had a wild ride in the final quarter of the year. The market plunged at the start of October on concerns that global growth was slowing. Then it rebounded and surged to record levels at the start of December, before falling sharply last week as the price of oil collapsed, dragging down energy stocks.

On Wednesday, energy stocks led gains for the S&P 500 index as the price of oil steadied. Stocks in the sector jumped 4.2 percent, reducing their losses for the year to 13 percent.

The price of U.S. oil rose Wednesday after the Energy Department reported a decline in inventories, a turnaround from a Tuesday report of increased inventories from the American Petroleum Institute, an industry group.

Benchmark U.S. crude rose 54 cents to close at $56.47 a barrel in New York. Brent crude for February delivery, a benchmark for international oils used by many U.S. refineries, rose $1.17 to close at $61.18 a barrel in London. The January Brent contract expired Tuesday at $59.86.

Stocks that were linked to Cuba surged after President Obama announced the reestablishment of diplomatic relations on Wednesday and declared an end to America's "outdated approach" to the communist island in a historic shift aimed at ending a half-century of Cold War enmity.

The Herzfeld Caribbean Basin Fund, a closed-end fund designed to take advantage of greater trade with Cuba, surged $1.97, or 28.9 percent, to $8.78.

In government bond trading, prices fell. The yield on the 10-year benchmark Treasury note, which rises when prices fall, climbed to 2.13 percent from 2.08 percent a day earlier.

In metals trading, the price of gold was little changed from Tuesday at $1,194.50 an ounce. Silver rose 18 cents to $15.93 an ounce and copper rose a penny to $2.87 a pound.

In other energy futures trading on the NYMEX, wholesale gasoline rose 2.5 cents to close at $1.57 a gallon; heating oil rose 4.9 cents to close at $2.01 a gallon, and natural gas fell 8.3 cents to close at $3.70 per 1,000 cubic feet.