Stocks edged higher on Monday, but pulled back from intraday peaks after a four-day rally that drove the major indexes to 10-month highs.

Stock investors retreated slightly after a sharp gain in U.S. Treasury prices, which drove benchmark yields lower.

Wall Street had rallied earlier, joining a global advance in equities and commodities, on Federal Reserve Chairman Ben Bernanke's optimistic comments and U.S. housing data last week.

The market is reacting to a U.S. Treasury market rally, said Peter Boockvar, equity strategist at Miller Tabak & Co, in New York.

We have been recently seeing a disconnect between the two markets. Stocks were up on economic optimism and bonds were up on economic concerns ... Investors are finally catching up with this, and seeing Treasuries as a sign that they should not be buying so much.

U.S. Treasury debt prices rose on Monday, with the 30-year bond gaining more than a full point as investors did some bargain hunting after Friday's sharp losses and the Federal Reserve bought government debt.

The semiconductor index <.SOXX> slipped 0.4 percent, while an index of bank shares <.BKX> edged up 0.1 percent.

Shares of chip maker Intel Corp fell 0.6 percent to $18.76, dragging on the Nasdaq.

JPMorgan Chase & Co shares inched up 0.1 percent, or 2 cents, to $43.68.

The Dow Jones industrial average <.DJI> advanced 20.25 points, or 0.21 percent, to 9,525.21, off a session high at 9,587.73. The Standard & Poor's 500 Index <.SPX> rose 1.94 points, or 0.19 percent, to 1,028.07. The Nasdaq Composite Index <.IXIC> gained 2.45 points, or 0.12 percent, to 2,023.35.

Earlier, the S&P 500 rose as high as 1,035.82, while the Nasdaq hit an intraday high at 2,036.03.

On the upside, drugmaker Warner Chilcott soared 31.4 percent to $21.11 after the company said it would buy Procter & Gamble Co's

pharmaceuticals business for $3.1 billion.

Stocks had little reaction to data from the Federal Reserve Bank of Chicago showing production-related indicators turned positive in July for the first time since October.

(Editing by Jan Paschal)