Speaker of the House John Boehner, R-Ohio, walks to the chamber as lawmakers vote to pay federal workers who have been furloughed during the government shutdown, at the Capitol in Washington, Saturday, Oct. 5, 2013. (AP Photo/J. Scott Applewhite)

WASHINGTON (AP) — Congress raced Wednesday to approve a bipartisan deal to avert a U.S. default and reopen the federal government, a move intended to end a prolonged fiscal crisis that battered Republican approval ratings and threatened the global economy with a new recession.

Republicans were left with little to show for their fight — in political terms, the final agreement was almost entirely along lines President Barack Obama had set when the impasse began last month. It includes nothing for Republicans demanding to eradicate or scale back Obama’s signature health care overhaul.

“We fought the good fight. We just didn’t win,” conceded House Speaker John Boehner as lawmakers lined up to vote on the bill.

The stock market surged higher at the prospect of an end to the crisis that had threatened to shake confidence in the U.S. economy overseas.

A Senate vote was set first on the legislation, which would permit the Treasury to borrow normally through Feb. 7 or perhaps a month longer, and fund the government through Jan. 15. More than two million federal workers — those who had remained on the job and those who had been furloughed — would be paid under the agreement.

Across the Capitol, members of the House marked time until their turn came to vote.

Boehner and the rest of the top Republican leadership told their rank and file they would vote for the measure, and there was little or no doubt it would pass both houses and reach the White House in time for Obama’s signature before Thursday’s deadline to increase the federal debt limit.

Obama applauded the Senate compromise and hoped to sign it into law, White House Spokesman Jay Carney said.

Boehner vowed Republicans were not giving up on the fight to bring down U.S. debt and cripple “Obamacare,” as the president’s signature health care overhaul is known.

“Our drive to stop the train wreck that is the president’s health care law will continue,” Boehner said in a statement.

Harry Reid, the Democratic Senate majority leader, thanked Sen. Mitch McConnell, the Republican minority leader, for working with him to end what had become one of the nastiest partisan battles in recent Washington history.

“This is a time for reconciliation,” Reid said.

A long line of polls charted a steep decline in public approval for Republicans in the course of what Republican Sen. John McCain pronounced a “shameful episode” in U.S. history.

The deal would end the bitter standoff for now, giving both parties time to cool off and come up with a broader budget plan or risk repeating the damaging cycle again in the new year.

The crisis began on Oct. 1 with a partial shutdown of the federal government after House Republicans refused to accept a temporary funding measure unless Obama agreed to defund or delay his health care law, known as “Obamacare.” It escalated when House Republicans also refused to move on needed approval for raising the amount of money the Treasury can borrow to pay U.S. bills, raising the specter of a catastrophic default. Obama vowed repeatedly not to pay a “ransom” in order to get Congress to pass normally routine legislation.

The hard-right tea party faction of House Republicans, urged on by conservative Sen. Ted Cruz of Texas, had seen both deadlines as weapons that could be used to gut Obama’s Affordable Care Act, designed to provide tens of millions of uninsured Americans with coverage. The Democrats remained united against any Republican threat to Obama’s signature program, and Republicans in the House could not muster enough votes to pass their own plan to end the impasse.

Cruz said after the deal was announced that he would not block a vote, a key concession that signaled a strong possibility that both houses could act by day’s end.

McConnell said the time had come to back away for now from Republican efforts to undermine “Obamacare.” But the feisty minority boss said Republicans had not given up on erasing it from the legislative books.

While the emerging deal could well meet resistance from conservatives in the Republican-controlled House, the Democratic Leader, Congresswoman Nancy Pelosi, signaled she will support the plan and her members were expected to vote for it in overwhelming numbers.

Passage will depend heavily on minority Democrats to support it. The risky move was seen as imperiling the House leadership, but Boehner was apparently ready to do it and end the crisis that has badly damaged Republican approval among voters.

Looking forward, lawmakers were also concerned voters would punish them in next year’s congressional elections. Polls show the public more inclined to blame Republicans.

Republican Sen. Lindsey Graham said the party had hurt its cause through the long and dangerous standoff.

“This package is just a joke compared to what we could have gotten if we had a more reasonable approach,” he said.

___

Associated Press writers David Espo, Steven R. Hurst, Alan Fram, Andrew Taylor, Charles Babington, Stephen Ohlemacher, Henry C. Jackson and Donna Cassata contributed to this report.

Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.