Stocks ended the week at 2009 highs on Friday after a surprising rise in home sales and optimistic comments from Federal Reserve chief Ben Bernanke reassured investors about the prospects for an economic recovery.

The S&P 500 and the Nasdaq hit 10-month intraday highs, while the Dow industrials rose to their highest level in nine months. The S&P 500 is now up 51.7 percent from its 12-year closing low set on March 9.

At the Fed's annual conference in Jackson Hole, Wyoming, Bernanke gave his clearest signal yet that the global economy is emerging from a recession. But the Fed chairman warned that growth would be sluggish for a time.

The home sales data got the market rolling, but Bernanke really persuaded investors to (keep up) the rally, said John Augustine, chief investment strategist at Fifth Third Asset Management in Cincinnati.

His comment was optimistic, but also prudent about the quantitative easing ending sometime. But the market took it all as good news.

The Dow Jones industrial average <.DJI> jumped 155.91 points, or 1.67 percent, to end at 9,505.96. The Standard & Poor's 500 Index <.SPX> climbed 18.76 points, or 1.86 percent, to 1,026.13. The Nasdaq Composite Index <.IXIC> rose 31.68 points, or 1.59 percent, to 2,020.90.

For the week, the Dow rose 2 percent, the S&P 500 gained 2.2 percent and the Nasdaq climbed 1.8 percent.

A stunning 7.2 percent jump in the July sales of previously owned homes gave stocks a shot of adrenaline. The steady rise for a fourth consecutive month to the highest level in almost two years suggested some easing in the housing crisis.

The data drove the Dow Jones U.S. Home Construction index <.DJUSHB> up 3.4 percent to 293.39. Among the big U.S. home builders, D.R. Horton advanced 3.4 percent to $12.66, while Toll Brothers gained 3.7 percent to $22.70.

In earnings-related news, J.M. Smucker climbed 4.3 percent to $54.10 after the company reported a higher first-quarter profit and gave a strong full-year outlook. [ID:nBNG465442] The company is known for its Smucker's brand jellies and jams, peanut butter and ice cream toppings.

The Nasdaq's advance was led by Apple Inc , up 1.7 percent at $169.22, and Microsoft Corp , up 3.1 percent at $24.41.

In New York Stock Exchange trading, American International Group shares climbed 1.7 percent to end at $32.85. Earlier, AIG's stock rose to an intraday high at $35.00 on news that the insurer had won dismissal of a federal lawsuit. [ID:nN21437830] The stock price has more than doubled since the start of the month.

Energy shares also grabbed the spotlight, with U.S. crude oil futures prices climbing to a 2009 high at $74.72 a barrel. The front-month crude oil contract gained 98 cents, or 1.3 percent, to settle on Friday at $73.89 a barrel on the New York Mercantile Exchange.

Chevron advanced 1.6 percent to $69.73 and Exxon Mobil gained 1.9 percent to $69.92.

Volume was moderate on the New York Stock Exchange, with 1.48 billion shares changing hands, just below last year's estimated daily average of 1.49 billion. On the Nasdaq, about 2.28 billion shares traded, matching last year's daily average.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of slightly more than 4 to 1. On the Nasdaq, about 20 stocks rose for every seven that fell.

(Editing by Jan Paschal)