The S&P and Nasdaq declined on Tuesday as commodity-related shares fell, with investors seeing pullbacks by some sectors that have gained the most in recent months.

Among Nasdaq decliners, shares of Sears Holdings fell more than 9 percent after the company said it will post a loss for the first quarter. First Solar also was down 1.9 percent at $134.90.

However, shares of Alcoa Inc shot up 3.3 percent to $17.78, helping to support the Dow, on talk in the market that Rio Tinto was lining up a bid to buy the U.S. aluminum producer. Neither Alcoa nor Rio Tinto would comment.

The energy sector, which gained 16 percent in the first quarter and outperformed the broader market, led losses on the S&P 500, followed by materials stocks. The S&P energy index <.GSPE> dropped 1.8 percent Tuesday.

You've had a tremendous run-up here, so you've got some profit-taking and an underlying rotation out of commodity shares into more defensive sectors, said Paul Mendelsohn, chief investment strategist at Windham Financial Services in Charlotte, Vermont.

My modeling tells me (commodities) are very, very overextended, which means a pullback in commodity sectors may be due, he said.

Among the market's defensive sectors, the S&P utilities index <.GSPU> was up 1.1 percent.

Mendelsohn said any pullback would likely be short term, and he sees the market on an upward trend.

The S&P is up about 30 percent since the start of September, with shares of commodities companies driving much of the rally.

Another solid earnings period further lifted the market in recent weeks, and estimates for S&P 500 company earnings growth keep rising.

Earnings now are expected to have risen 18 percent in the quarter, compared with an April 1 forecast for 13 percent, according to Thomson Reuters data.

The Dow Jones industrial average <.DJI> was up 0.83 point, or 0.01 percent, at 12,808.19. The Standard & Poor's 500 Index <.SPX> was down 4.74 points, or 0.35 percent, at 1,356.48. The Nasdaq Composite Index <.IXIC> was down 26.37 points, or 0.92 percent, at 2,837.71.

Larger-cap stocks were outperforming small caps, suggesting a risk-off trade may be taking place, Mendelsohn said. The Russell 2000 <.RUT> index was down 1.2 percent after hitting lifetime highs last week.

A Reuters poll showed on Tuesday that U.S. fund managers slightly lowered their exposure to equities in April and raised their allocation in bonds.

Investors may be cautious before Friday's key report on U.S. jobs, still one of the weakest areas of the U.S. economy, Mendelsohn said.

Among companies reporting results, MasterCard Inc shares rose 2.7 percent to $282.64 after the world's second-largest credit card processing network posted a 24 percent jump in quarterly profit.

(Reporting by Caroline Valetkevitch; Editing by Kenneth Barry)