Financial stocks led the Dow higher. Its biggest gainers were Bank of America, up 2.2 percent, and JPMorgan Chase, up 1.8 percent. Financial stocks have been the best performers in the market this year.
The market's gains were broad-based, with nine of 10 stock categories in the Standard & Poor's 500 rising, led by industrial stocks. Utilities declined by a whisker. European stocks rose.
For once, investors had the Greek parliament to thank. On Sunday, it approved sharp cuts in civil service jobs, welfare, and the minimum wage, required by international leaders for a $170 billion bailout that Greece must have to avoid defaulting on its debt. Other details of the bailout still need to be finalized, though.
The Dow closed up 72.81 points, or 0.6 percent, at 12,874.04. It is 16 points shy of its highest close since the 2008 financial meltdown.
The S&P rose 9.13 points, or 0.7 percent, to 1,351.77.
The Nasdaq composite rose 27.51 points, or 1 percent, to 2,931.39.
The Greek debt deal appeared to take some pressure off U.S. banks. Moody's Investors Services said the $25 billion settlement between mortgage lenders and states over foreclosure practices was a negative for all five major banks involved. Still, most major banks, which have varying levels of exposure in Europe, gained on Monday. The euro fell a fraction of a penny against the dollar, to $1.32.
In Europe, the FTSE 100 in Britain rose 0.9 percent to 5,906. Germany's DAX rose 0.7 percent to 6,738. The CAC-40 in France rose slightly to 3,385. In Athens, stocks rose 4.6 percent.
In Asia, Japan's Nikkei 225 closed 0.6 percent higher at 8,999, and Hong Kong's Hang Seng gained 0.5 percent.
Investors were not ready to leave the haven of bonds in great numbers. Prices bounced between gains and losses as traders appeared skeptical that Greece was past its debt problem. The yield on the 10-year Treasury note was 1.98 percent, flat from Friday.
Oil rose to $100.49 per barrel in New York. Gold rose slightly to $1,726.60 per ounce.
Among stocks in the news was ATM maker Diebold Inc., which rose 9 percent after reporting strong sales to banks, a sign they may be willing to spend more to upgrade their technology.