U.S. stocks rose for a second consecutive day on Tuesday, led by gains in shares of Goldman Sachs and strength in beaten-down homebuilders and raw materials companies.

Goldman Sachs Group Inc rose 2.2 percent as buyers materialized after an early selloff on news the investment bank's quarterly earnings tumbled 82 percent, steeper than forecast.

Most stocks opened weaker, so it was a buying opportunity for people willing to take the risk, said Peter Costa, president at Empire Executions in New York.

The Dow Jones industrial average <.DJI> rose 75.53 points, or 0.74 percent, to 10,229.96. The Standard & Poor's 500 Index <.SPX> gained 12.23 points, or 1.14 percent, to 1,083.48. The Nasdaq Composite Index <.IXIC> added 24.26 points, or 1.10 percent, to 2,222.49.

Stock could extend gains for a third straight day as futures rose after Apple Inc reported results that surpassed Wall Street's forecasts.

Shares of Apple, maker of the iPhone and iPad, gained 3.2 percent to $260 in extended-hours trading.

BUYERS COME IN LATE

Some market analysts said the late buying during the regular session was driven in part by speculation that the Federal Reserve would take steps to spur lending by eliminating interest paid on excess bank reserves held at the Fed.

The S&P 500 hit a session low near a key support level of 1,060, the 23.6 percent retracement of the index's 2010 high-to-low slide.

Housing starts fell more than expected in June, the government said, but applications for building permits, a measure of future activity, unexpectedly rose.

It looks like things have turned around on economic news, which was better than earnings today, said Andy Fitzpatrick, director of investments at Hinsdale Associates, in Hinsdale Illinois.

Weyerhaeuser Timber Co shot up 3.9 percent to $15.96 and the Morgan Stanley housing index <.HGX> gained 4.2 percent.

The materials sector <.GSPM>, up 2.9 percent, led gains on the S&P 500, helped by a 2.5 percent jump in copper futures -- the largest daily percentage gain in almost a month.

Despite some indicators signaling a possibly overbought level, investment bank Goldman Sachs' technical momentum and its moving average convergence divergence point to a near-term rally.

Short-term, the stock has a decent shot to move back up to around a $165-$175 potential target, said Vinny Catalano, investment strategist with Blue Marble Research in New York.

The S&P energy index <.GSPE> was up 1.9 percent, helping to underpin the market. Crude oil settled up 1.2 percent at $77.44 per barrel.

REVENUE MISSES ARE PUNISHED

International Business Machines Corp fell 2.5 percent to $126.55 a day after reporting quarterly revenues missed estimates as new technology services contracts declined. IBM, the world's biggest technology services company, was the top drag on the Dow.

Texas Instruments Inc also missed revenue expectations due to weaker-than-expected orders from one mobile phone customer, and shares of the chipmaker dropped 3 percent to $24.78.

In after-hours trading, Internet company Yahoo Inc dropped 6.3 percent to $14.25 after net revenue fell short of Wall Street expectations.

About 8.22 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq during regular hours, below last year's estimated daily average of 9.65 billion.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of more than 4 to 1, while on the Nasdaq, about 12 stocks rose for every five that fell.

(Additional reporting by Ryan Vlastelica; Editing by Kenneth Barry)