Stocks posted their best day in the last nine on Thursday in response to signs of health in the euro debt market and as investors snapped up energy shares crushed in the previous day's sell-off.

The energy sector led a broad advance with all but four stocks in the S&P 500 finishing the day higher.

The S&P energy sector <.GSPE> gained 4.9 percent. New York-traded shares of BP plc jumped 12.3 percent to $32.78 a day after posting a near 16 percent decline. Baker Hughes Inc shot up 10.6 percent to $42.42 after a JPMorgan upgrade.

Spain sold 3.9 billion euros of a 3-year benchmark bond seeing strong demand, a positive sign for investors worried about appetite for debt from struggling European nations. The euro rose 1.2 percent against the U.S. dollar, trading above $1.21.

China confirmed exports jumped nearly 50 percent in May from a year ago, reassuring investors worried about the impact of the European crisis on global growth.

The Spanish bond market auction went well and the strength in Chinese export numbers was beneficial, said Brian Lazorishak, portfolio manager at Chase Investment Counsel of Charlottesville, Virginia.

You had incrementally good news on many of the biggest downside drivers of the market.

The Dow Jones industrial average <.DJI> jumped 273.28 points, or 2.76 percent, to 10,172.53. The Standard & Poor's 500 Index <.SPX> rose 31.15 points, or 2.95 percent, to 1,086.84. The Nasdaq Composite Index <.IXIC> gained 59.86 points, or 2.77 percent, to 2,218.71.

The S&P 500 posted a bullish technical alert as its daily moving average convergence-divergence, or MACD, a widely followed momentum indicator, generated a buy signal. The S&P and the Dow closed above their 14-day moving average, another short-term bullish sign.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of about 7 to 1, while on the Nasdaq, about 11 stocks rose for every two that fell.

Further boosting energy shares, crude futures settled up 1.5 percent, or $1.10, at $75.48 a barrel lifted by the Chinese data and after the International Energy Administration raised its estimate for growth in oil demand in 2010.

Housing stocks soared after U.S. Senate Majority Leader Harry Reid proposed an extension to a part of a homebuyer tax credit.

Radian Group jumped 10.3 percent to $8.98 and Lennar Corp gained 8 percent to $15.58. the Morgan Stanley housing index <.HGX> rose 4.7 percent.

On the downside, Goldman Sachs Group Inc fell 2.2 percent to $133.77 and was the S&P 500's top percentage decliner. A source familiar with the situation said the Securities and Exchange Commission, which charged Goldman with fraud in April, is investigating another mortgage-linked deal once pitched by the Wall Street firm.

About 9.16 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, below last year's estimated daily average of 9.65 billion.

Before the opening bell, the U.S. government reported that the number of new filings for unemployment benefits fell less than expected last week, while the international trade deficit widened slightly in April, pointing to a moderate economic recovery.

(Reporting by Rodrigo Campos; Editing by Jan Paschal)