NEW YORK (AP) -- 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, pushing the Standard & Poor's 500 index close to a record high.
On Wednesday, Senate leaders agreed to fund the government through Jan. 15 and allow government borrowing through Feb. 7. The government has been partially shut for 16 days because House Republicans had demanded changes to the President Obama's health care law before passing a budget.
Wednesday's Senate deal was reached just hours before a Thursday deadline that Treasury Secretary Jacob Lew had set to raise the $16.7 trillion debt limit.
The agreement follows a month of rancorous political gridlock that threatened to make America a deadbeat and derail global financial markets. Even so, investors have stayed largely calm throughout in the current drama in Washington, with the S&P 500 actually gaining 2.1 percent since the shutdown began on Oct. 1.
Wall Street had bet big that politicians wouldn't let U.S. default, a calamity economists said could paralyze lending, slow the economy and cause another recession.
If the deal wraps up soon, investors can turn their attention back to basics like earnings and the economy. Corporations have begun to report third-quarter earnings, but Wall Street has been glued to the budget brinksmanship. Overall earnings growth for companies in the S&P 500 is forecast at 3.13 percent from a year earlier. That's slower than growth of 4.9 percent in the second quarter and 5.2 percent in the first quarter.
It'll be harder for Wall Street to get up-to-date view of the economy because the partial government shutdown since Oct. 1 has kept agencies from releasing key reports on trends like hiring. In general, though, the economy has been expanding this year.
Traders have been correctly betting that Washington would reach a deal. To be sure, 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.
The feeling among stock traders in recent days was that panicking and pulling money out of stocks could leave them missing out on a rally after Washington finally came to an agreement. Investors are also becoming 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. would go over the "fiscal cliff" as lawmakers argued over a series of automatic government spending cuts. Stock also rebounded and embarked on a strong rally that has pushed 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 stock 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."
Among stocks making big moves:
— Bank of America rose 28 cents, or 2 percent, to $14.52 after the second-largest U.S. bank reported a surge in third-quarter earnings.
— Stanley Black & Decker plunged $12.90, or 14.5 percent, to $76.54 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 Writers Ken Sweet and Steve Rothwell contributed to this report.