Stocks rallied on Monday on relief over a last-ditch deal in Washington to raise the U.S. borrowing limit and avert an unprecedented default, though analysts said the gains could be short-lived.

Lawmakers were due to vote later Monday on the White House-backed agreement, which includes spending cuts of $2.4 trillion over 10 years. The deal was seen passing the Democratic-led Senate, but faced tougher opposition in the U.S. House of Representatives, where both conservative Tea Party supporters and liberal lawmakers have criticized it.

Even though a default was considered unlikely by many investors, equities grew increasingly volatile as Washington was stalemated. Wall Street suffered its worst week in a year last week.

We're not seeing a bigger rally now because a deal was expected. The only surprise is how close negotiations came to the wire before potential Armageddon, said Neal Neilinger, chief investment officer at Aladdin Capital in Stamford, Connecticut, which manages $10.5 billion in assets. As the day goes on, it's likely you'll see some profit-taking.

The Dow Jones industrial average <.DJI> jumped 72.13 points, or 0.59 percent, at 12,215.37. The Standard & Poor's 500 Index <.SPX> put on 7.84 points, or 0.61 percent, at 1,300.12. The Nasdaq Composite Index <.IXIC> was up 18.35 points, or 0.67 percent, at 2,774.73.

Gold, seen as a safe haven in times of economic uncertainty, fell more than 1 percent before recovering to stand just half a percent down. September crude futures climbed 2.2 percent. The Select Sector Energy SPDR Fund rose 0.7 percent.

Even with an agreement, many investors were concerned about a possible downgrade of the United States' AAA sovereign debt rating, as well as European sovereign debt problems. The FTSEurofirst 300 <.FTEU3> index of top European shares dipped 0.3 percent.

The deal lowers the odds of a downgrade, but it doesn't make it go away, said Wayne Kaufman, chief market analyst at John Thomas Financial in New York. People still have question marks in their minds about what comes next.

In earnings news, Allstate Corp recorded a second-quarter loss that was narrower than expected, while insurer Humana Inc raised its full-year profit view.

Allstate gained 2.6 percent to $28.45, and Humana advanced 0.4 percent to $74.79.

HSBC Holding Plc reported a surprise first-half profit and said it would cut 30,000 jobs as it retreats from countries where it is struggling to compete. U.S.-listed shares of the bank rose 2.3 percent to $49.98.