Stocks rose on Tuesday to 2009 highs after stronger manufacturing and retail sales data boosted commodity prices and shares of materials companies.

Tuesday's gains lifted the S&P 500 above 1,050 for the first time since early October.

The improvement in retail sales in August reassured investors about a rebound in U.S. economic demand. A rise in the government's Producer Price Index signaled increased consumption of raw materials.

Metals prices rose, sending shares of aluminum company Alcoa up 8 percent, while steelmakers AK Steel rose 5.7 percent and US Steel gained 4.8 percent.

The Reuters-Jefferies CRB index of commodity prices <.CRB> jumped 2.2 percent for its biggest gain in more than a month, while the S&P materials sector <.GSPM> added 2.4 percent.

The rise in producer prices and a report showing stronger New York state manufacturing suggested demand is building for raw materials.

To make things, you need stuff that comes from the ground, at least at the beginning of a recovery from recession, said Kim Caughey, senior equity research analyst at Fort Pitt Capital Group in Pittsburgh.

Comments by Federal Reserve Chairman Ben Bernanke that the recession was probably at an end also favored basic materials companies, Caughey said.

Bernanke, speaking on the one-year anniversary of the collapse of Lehman Brothers , said the recession is very likely over.

The Dow Jones industrial average <.DJI> was up 56.61 points, or 0.59 percent, at 9,683.41. The Standard & Poor's 500 Index <.SPX> was up 3.29 points, or 0.31 percent, at 1,052.63. The Nasdaq Composite Index <.IXIC> was up 10.86 points, or 0.52 percent, at 2,102.64.

A stronger-than-expected rise in retail sales notwithstanding, shares of retailers got hit by disappointing results from Best Buy Co Inc and Kroger Co , both of which reported quarterly profits below expectations.

Shares of electronics store Best Buy fell 5.2 percent to $38.32 while grocer Kroger slid 7.5 percent to $20.46. The S&P Retail index <.RLX> was down 0.1 percent.

Shares of General Electric jumped 4.2 percent to $16, helped by an upwardly revised price target from Bernstein Research. The conglomerate's sharp rebound of about 170 percent from its 2009 lows could be a harbinger of more gains for the broader stock market in the months ahead, said Richard Ross, global technical strategist at Auerbach Grayson.

The Nasdaq got a boost after analysts' upgrades of Web auctioneer eBay and Internet company Yahoo . Yahoo shares climbed 5.4 percent to $16.41 while eBay added 1.3 percent to $24.14.

Alcoa rose to $13.99, AK Steel advanced to $23.11 and U.S. Steel rose to $48.98.

(Additional reporting by Ellis Mnyandu; Editing by Kenneth Barry)