The Dow jumped 323.09 points, or 2.2 per cent, to close at 15,126.07. It was the index's biggest point rise this year.
The Standard & Poor's 500 index rose 36.16 points, or 2.2 per cent, to 1,692.56 and the Nasdaq composite rose 82.97 points, or 2.3 per cent, to 3,760.75.
Stocks have steadily declined since mid-September as Washington's gridlock got investors worried that the US could default on its debt and wreak havoc on global financial markets. While traders applauded the deal between the White House and Congress, more volatility could be ahead if a deal falls through.
"We don't need some grand bargain, we just need to avoid a default," said Brian Reynolds of chief market strategist at Rosenblatt Securities. "Just don't bring us to the edge again."
Thursday's gains were extraordinarily broad. Of the 500 stocks in the S&P 500 index, only 11 fell. Banks and industrial stocks rose the most.
A potential compromise between the two political parties could not come soon enough. Treasury Secretary Jack Lew has said the government will hit its borrowing limit on Oct. 17. That would leave the US with enough cash to last just a week or two before a default became a real risk.
A short-term extension of the debt limit is "the right approach," said Jack Ablin, who manages $66 billion as chief investment officer at BMO Private Bank.
"It allows politicians to turn down the heat a bit while still keeping the broader issues on the front burner," Ablin said.
In another bullish signal, small-company stocks rose even more than the rest of the market. Those stocks tend to be riskier than large, well-established companies but can also offer investors greater rewards. A sharp increase in small-company stocks means investors are more comfortable taking on risk. The Russell 2000 index jumped 26.04 points, or 2.5 per cent, to 1,069.50.
There were hopeful signs in the market for short-term US government debt. The yield on the one-month Treasury bill eased to 0.25 per cent from 0.27 late Wednesday.
The yield had spiked from near zero at the beginning of the month to as high as 0.35 per cent Tuesday as investors dumped the bills out of concern that the government might not be able to pay them back when they're due. Investors demand higher yields when they perceive debt as being risky.
On major investor made a move to cut its exposure to short-term US government debt. Fidelity Investments, the nation's largest money market fund manager, said Wednesday it had sold all of its short-term US government debt.
-AP