Stocks rose slightly on Thursday as investors focused on stronger-than-expected sales by key retailers in August, offsetting weak labor-market data.

The retailers' sales, along with a survey showing the U.S. services sector in August was at its strongest in nearly a year, boosted stocks, countering higher-than-forecast initial claims for jobless benefits.

Gains were modest, however. In the four prior sessions, stocks had been unable to build upon relatively strong data, showing little conviction at the outset of September, traditionally a weak month for the market.

The market now seems to be reacting negatively to positive news, and that's a change that has to be noted, said Carl Birkelbach, chairman and chief executive of Birkelbach Investment Securities in Chicago.

Costco Wholesale Corp and Target Corp were among retailers posting higher-than-expected sales in August.

Costco's shares, which were subsequently upgraded by JPMorgan, climbed 8.6 percent to $55, while Target gained 1.6 percent to $47.02. The S&P retail index <.RLX> rose 1.4 percent.

The Dow Jones industrial average <.DJI> gained 30.53 points, or 0.33 percent, to 9,311.20. The Standard & Poor's 500 index <.SPX> gained 3.68 points, or 0.37 percent, to 998.43. The Nasdaq composite index <.IXIC> gained 7.39 points, or 0.38 percent, to 1,974.46.

Mining shares rose, with Newmont Mining Corp up 2.7 percent to $44.99 and Freeport-McMoRan Copper & Gold Inc up 2.9 percent to $63.62 as spot gold prices hit an intraday peak of $992.55, the highest level since late February.

The PHLX Gold/Silver index <.XAU> gained 3.4 percent.

Credit-rating agency Moody's Corp and McGraw-Hill Cos , the parent of credit-ratings firm Standard & Poor's, slid after a federal judge ruled the two companies must defend fraud charges in a class-action lawsuit accusing them of masking the risks of an investment linked to subprime mortgages.

McGraw-Hill shares dropped 6.9 percent to $30.09 while Moody's shed 9.7 percent to $23.56.

Government data showed initial jobless claims fell to 570,000 from a revised 574,000 the week before, but that was above economists' forecast for 560,000 claims.

The Institute for Supply Management said its services index rose to 48.4 in August, slightly above the 48.0 median forecast of economists surveyed by Reuters.

(Reporting by Chuck Mikolajczak; Editing by Kenneth Barry)