New York: Wall Street finally got the deal it's been waiting for.
A last-minute agreement to keep the U.S. from defaulting on its debt and reopen the government sent the stock market soaring Wednesday, lifting the Standard & Poor's 500 index close to a record high.
The deal was reached just hours before a deadline to raise the nation's $16.7 trillion debt limit. Senate leaders agreed to extend government borrowing through Feb. 7 and to fund the government through Jan. 15.
The agreement follows a month of political gridlock that threatened to make America a deadbeat and derail global markets, which depend on the U.S. to pay its bills. American government debt is widely considered the world's safest investment.
Markets stayed largely calm throughout the drama in Washington, with the S&P 500 actually gaining 2.4 percent since the shutdown began Oct. 1, after House Republicans demanded changes to President Barack Obama's health care law before passing a budget.
Wall Street gambled that politicians wouldn't let the U.S. default, a calamity economists said could paralyze lending and push the economy into another recession.
"We knew it was going to be dramatic, but the consequences of a U.S. default are just so severe that the base case was always that a compromise was going to be reached," said Tom Franks, a managing director at TIAA CREF, a large retirement funds manager.
Congress was racing to pass the legislation before the Thursday deadline.
If the deal wraps up soon, investors can turn their attention back to economic basics like third-quarter earnings. Overall earnings at companies in the S&P 500 index are forecast to grow 3.1 percent from a year earlier, according to data from S&P Capital IQ. That's slower than the growth of 4.9 percent in the second quarter and 5.2 percent in the first quarter.
It will be harder for Wall Street to get an up-to-date view of the economy because the partial government shutdown that began Oct. 1 has kept agencies from releasing key reports on trends like hiring. In general, though, the economy has been expanding this year.
Despite broad confidence that the political parties would strike a deal, the Dow went through rough patches over the last month, at one point falling as much as 900 points below an all-time high reached on Sept. 18. The Dow has seen seven triple-digit moves in the last 10 trading days.
On Wednesday, the Dow Jones climbed 205.82 points, or 1.4 percent, to 15,373.83. The S&P 500 gained 23.48, or 1.4 percent, at 1,721.54. That's only four points below its record close of 1,725.52 set Sept. 18.
The Nasdaq composite climbed 45.42, or 1.2 percent, to 3,839.43.
The feeling among stock traders in recent days was that panicking and pulling money out of stocks could mean missing out on a rally after Washington came to an agreement. Investors have also become inured to Washington's habit of reaching budget and debt deals at the last minute.
"Investors have become, unfortunately, accustomed to some of the dysfunction," said Eric Wiegand, a senior portfolio manager at U.S. Bank. "It's become more the norm than the exception."
In the summer of 2011, the S&P 500 index plunged 17 percent between early July and early August as lawmakers argued over raising the debt limit, and Standard & Poor's cut the U.S. credit rating from AAA, its highest ranking. The market later recovered.
Stocks also slumped in the last two weeks of 2012 as investors fretted that the U.S. could go over the "fiscal cliff" as lawmakers argued over a series of automatic government spending cuts. Stocks rebounded and began a strong rally that has propelled the S&P 500 up almost 21 percent this year.
Some were glad that investors could now turn their focus back to the traditional drivers of the market rather than worrying whether the latest dispatch from Washington would shake stocks.
"It's a little bit silly in the short term for markets to go down so much on press conferences and then to go up so much on rumors," said Brad Sorensen, director of market and sector research at the Schwab Center for Financial Research. "We've urged investors to pull back a little bit and look at the longer term."
The market for U.S. Treasury bills reflected relief among bond investors. The yield on the one-month T-bill dropped to 0.13 percent from 0.40 percent Wednesday morning, an extraordinarily large move. The decline means that investors consider the bill, which would have come due around the time a default may have occurred, to be less risky.
The yield on the 10-year Treasury note edged down to 2.67 percent from 2.74 percent Tuesday. Yields on longer-term U.S. government debt haven't moved as much as those on short-term debt because investors believed that the government would work out a longer-term solution.
Among stocks making big moves:
— Bank of America rose 32 cents, or 2.2 percent, to $14.56 after the second-largest U.S. bank reported a surge in third-quarter earnings.
— Stanley Black & Decker plunged $12.70, or 14.3 percent, to $76.75 after the company lowered its profit forecast for the year, citing slower growth in emerging markets and a hit from the U.S. government shutdown.
AP Markets Writer Ken Sweet contributed to this report.