Republican leaders conceded defeat in their two-week battle to derail Barack Obama's health care reforms on Wednesday, agreeing to a series of votes that were likely to re-open the government and avert a looming debt default.
With just hours to go until a deadline set by the Treasury department for extending the US debt limit, House leader John Boehner signalled he was ready to accept a Senate-drafted peace deal that contained almost no concessions to conservatives who had driven the country the brink of a new financial crisis.
Harry Reid, the Senate majority leader, announced the deal on the the floor of the Senate just after 12 noon. He called for all sides to work together to implement the deal. "Now is not the time for pointing fingers," he said.
Mitch McConnell, the Republican minority leader, acknowledged the fight was over and said the shutdown and debt crisis should be over later on Wednesday. "This has been a long, challenging few weeks," he said. "This is far less than many of us had hoped for, but it is far better than some had sought."
The deal crafted by McConnell and Democratic majority leader Harry Reid will fund the government until 15 January and lift the debt ceiling until 7 February. It will force both sides into a formal budget conference to try to reach a longer-term deal by 13 December.
The only apparent change to the Affordable Care Act, which Republicans had targeted in their budget standoff, involves asking the Obama administration to carry out better checks on the incomes of those applying to take part in new insurance exchanges.
A senior Republican aide told the Guardian that Boehner had agreed to allow the House to vote on the deal, which in practice means it would pass with support from Democrats and moderate Republicans, although it was still unclear when this would happen.
Recriminations among Republicans flew thick and fast, with moderates accusing House conservatives of trashing the party's reputation in pursuit of an impossible ambition to repeal Obamacare entirely.
Senator Lindsey Graham, of South Carolina, said this had "been the best two weeks for the Democratic Party in recent times".
"When we evaluate the last couple of weeks it should be entitled the time of great lost opportunity. If we had been focused on the roll-out of Obamacare and its confusion, public support would have diminished. Instead, our numbers have gone down, Obamacare has mysteriously gone up and other than that this has been great."
He was scathing about the influence of conservative advocacy groups such as Heritage Action, which torpedoed a deal on Tuesday when it threatened to withdraw support from Republicans who backed it, but blamed lawmakers for listening to them.
"Every member of Congress gets hit by groups like this right and left. I am not mad at a group for wanting their way; I am focusing on trying to get the Republican party to chart a better way. The way we are behaving and the path we have taken the last couple of weeks leads to a marginalised party in the eyes of the American people. A form of conservatism that is probably beyond what the market would bear. "
If, as expected the House votes on the new deal first, it would prevent Cruz from delaying its passage through the Senate and could herald an end to the crisis by Wednesday night.