Stocks surged to 2009 highs on Friday after a surprising increase in existing home sales offered solid evidence of a recovery and positive comments from Federal Reserve Chairman Ben Bernanke bolstered optimism about the economy.

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 is now up 51 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 a recovery is at hand, but warned that it 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> shot up 136.11 points, or 1.46 percent, to 9,486.16. The Standard & Poor's 500 Index <.SPX> rose 16.49 points, or 1.64 percent, to 1,023.86. The Nasdaq Composite Index <.IXIC> gained 25.23 points, or 1.27 percent, to 2,014.45.

A surprising 7.2 percent jump in the July sales of previously owned homes gave stocks a shot of adrenaline. It was the fourth straight monthly increase and the highest level of existing home sales since August 2007.

The data drove the Dow Jones U.S. Home Construction index <.DJUSHB> up 3.5 percent to 293.68. Among the big U.S. home builders, D.R. Horton advanced 4.1 percent to $12.74, while Toll Brothers gained 3.8 percent to $22.73.

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

American International Group shares gained 2.2 percent to $33.02. The stock rose as much as 8.4 percent earlier in the session to an intraday high at $35.00 on news that AIG had won dismissal of a federal lawsuit that accused it of fraudulently shortchanging state workers' compensation pools out of more than $1 billion. Its 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.34 percent, to settle on Friday at $73.89 a barrel on the New York Mercantile Exchange.

Chevron advanced 1.5 percent to $69.62 and Exxon Mobil gained 1.7 percent to $69.74.

(Editing by Jan Paschal)