Stocks recorded their best day since March on Tuesday after strong corporate results and renewed hope for an agreement in Washington on thorny budget issues boosted investor confidence.

Quarterly numbers from technology bellwether International Business Machines Corp and Coca-Cola lifted technology and consumer shares in the first heavy week of second-quarter results. IBM gained 5.7 percent, leading the Dow's gainers.

The Nasdaq gained more than 2 percent, led by big-cap tech, including Apple , which hit a 52-week high. The S&P information technology sector <.GSPT> was the best performing sector, gaining 2.7 percent.

Markets gained momentum late in the day after President Barack Obama suggested progress was being made toward a $3.75 trillion deficit reduction deal centered around entitlement reform.

The White House and Congress also need to sign an agreement that includes an increase in the federal debt ceiling by August 2 or the United States could default on its debt.

Stocks are starting to bounce at least for the time being, with people wagering that there will be a resolution on the debt ceiling, said Wayne Kaufman, chief market analyst at John Thomas Financial in New York.

All 10 S&P 500 sectors rose on Tuesday, even shares of financials, which were hit by declines in Goldman Sachs Group Inc and Bank of America following their earnings results. After advancing in the morning, Bank of America shares fell 1.5 percent to $9.57, while Goldman declined 0.6 percent to $128.49.

Wells Fargo shares jumped 5.7 percent, the biggest gain on the S&P financials index, after the bank said its profit rose 30 percent.

In terms of the overall earnings season, I'd say things have been pretty good so far, said Phil Orlando, chief equity strategist at Federated Investors. But again, we are only about eight days in and we need to see another week or two of data to begin to get a better tone of the quarter.

The Dow Jones industrial average <.DJI> was up 202.11 points, or 1.63 percent, at 12,587.27. The Standard & Poor's 500 Index <.SPX> was up 21.27 points, or 1.63 percent, at 1,326.71. The Nasdaq Composite Index <.IXIC> was up 61.41 points, or 2.22 percent, at 2,826.52.

Goldman's second-quarter net income fell short of lowered expectations as fixed income trading revenue dropped sharply. Bank of America recorded a second-quarter net loss of $8.8 billion.

Coca-Cola Co posted slightly higher-than-expected profit. Shares rose 3.3 percent to $69.32.

Housing starts hit a six-month high in June. The PHLX Housing Index <.HGX> rose 3 percent.

Volume was light with about 7.01 billion shares traded on the New York Stock Exchange, NYSE Amex and Nasdaq, below the daily average of 7.49 billion.

About four stocks rose for every one that fell on the New York Stock Exchange and the Nasdaq.

(Reporting by Ashley Lau; Additional reporting by Daniel Bases; Editing by Kenneth Barry)