Stocks gained on Thursday after data showed factory activity cooled in August but was still expanding, easing investors' fears the economy could be headed for another recession.

Energy and information technology stocks led the market higher. The S&P energy sector index .GSPE rose 0.6 percent and the information technology sector .GSPT gained 0.2 percent.

Wall Street started off little changed, but rose after the Institute for Supply Management (ISM) factory activity index stayed above 50, the expansion threshold. The reading was 50.6, down from 50.9 in the previous month, but topped the forecast of 48.5.

Relative to the fear that was in the markets a few weeks ago, ISM wasn't too bad. The fact that we're getting confirmation that some numbers aren't too bad is encouraging, said Mark Foster, who helps manage $500 million at Kirr Marbach & Co in Columbus, Indiana.

The Dow Jones industrial average .DJI was up 32.51 points, or 0.28 percent, at 11,646.04. The Standard & Poor's 500 Index .SPX was up 2.28 points, or 0.19 percent, at 1,221.17. The Nasdaq Composite Index .IXIC was up 7.75 points, or 0.30 percent, at 2,587.21.

The Nasdaq was supported by Ciena Corp (CIEN.O) which jumped 19.3 percent to $14.63. The communication equipment maker posted a profit for the first time in three years, surprising analysts who expected another loss, as cost cuts helped boost margins.

U.S. construction spending fell unexpectedly in July as public construction outlays dropped to their lowest level since December 2006 and private spending also sagged, separate data showed.

Weekly jobless claims declined by 12,000 in the latest week, while nonfarm productivity was weaker than previously thought in the second quarter.

(Reporting by Angela Moon; editing by Jeffrey Benkoe)