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, 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 extend government borrowing through Feb. 7.
The 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 government has been partially shut for 16 days because House Republicans had demanded changes to President Barack Obama's health care law before passing a budget.
The agreement follows a month of political gridlock that threatened to make America a deadbeat and derail global financial markets. Investors have stayed largely calm throughout in the current drama in Washington, with the S&P 500 actually gaining 2.4 percent since the shutdown began on Oct. 1.
Wall Street had bet 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 Wednesday.
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 at companies in the S&P 500 index is 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.