U.S. stocks surged and the yen weakened against all major peers as the Senate crafted a deal to end the government shutdown and raise the debt ceiling. Rates on Treasury bills retreated while energy led commodities higher.

The Standard & Poor’s 500 Index climbed 1.4 percent to 1,721.54 at 4 p.m. in New York, erasing yesterday’s drop and rising to within 0.3 percent of its last closing record. The Stoxx Europe 600 Index added 0.2 percent after earlier losing 0.6 percent. The yen fell 0.6 percent versus the dollar. Rates on Oct. 24 Treasury bills lost 27 basis points to 0.20 percent, erasing an earlier surge. The 10-year note yield decreased six basis points to 2.67 percent while the S&P GSCI Index of commodities climbed 0.8 percent as oil rallied 1.1 percent.

The Senate and House could vote as soon as today on the agreement that would end the 16-day-old government shutdown and allow the U.S. to continue borrowing, a day before its authority lapses. House Republicans today signaled that they will let it pass largely with Democratic votes. Senate opponents of the agreement, including Texas Republican Ted Cruz, said they won’t stall a vote.

“Our clients always assumed the deal would get done somewhere around the last minute,” Dan Greenhaus, chief global strategist at BTIG LLC in New York, said in a phone interview. “There was never really a deviation from that view. I don’t think anybody should or will get too excited about a short term deal. We’ll just have to deal with this idiocy again towards the end of the year. That shouldn’t make anybody happy.”

Senate leaders stepped in after House Republicans’ last-minute plan to avert a U.S. default collapsed. Federal Reserve Bank of Dallas President Richard Fisher said the central bank could reduce the turmoil from any U.S. debt default, which he said is unlikely. Fitch Ratings put the government of the world’s biggest economy on watch for a possible credit downgrade yesterday, citing lawmakers’ inability to forge a deal.

The White House press secretary said President Barack Obama supports the deal. Representative Kevin Brady, a Texas Republican, said on Bloomberg Television that he thinks House Republicans’ inability to come up with a plan to raise the debt limit meant that House Speaker John Boehner would have to accept whatever Senate leaders agreed upon.

“If Boehner is going to bring this to a vote on the floor, then we’re closer to getting a resolution to this, and the markets are pricing that in,” Stephen Wood, New York-based chief market strategist at Russell Investments, where he helps oversee about $237 billion, said by phone.

The S&P 500 rebounded from yesterday’s 0.7 percent drop as all 10 of its main industry groups advanced, led by financial, health-care and telephone shares. Bank of America Corp. jumped 2.2 percent as lower legal expenses and loan losses helped profit rebound. Mattel Inc. increased 1 percent after reporting earnings that topped analyst estimates.

JPMorgan Chase & Co., Goldman Sachs Group Inc. and Visa Inc. jumped at least 2.2 percent to lead gains in 27 of 30 stocks in the Dow Jones Industrial Average, sending the gauge up more than 205 points.

The Nasdaq Composite Index climbed 1.2 percent to the highest level in 13 years while the Russell 2000 Index and Dow Jones Transportation Average both closed at records.