Government employees return to work and financial crisis averted after bill passes Congress with no concessions to hardliners

The US Congress passed legislation to rescue the country from the brink of a looming debt default on Wednesday night, bringing an end to the two-week crisis that has closed large portions of the government, revealed deep divisions in the Republican party and threatened a global financial crisis.

A temporary fix that will last only through to the start of 2014, the bill passed easily with broad bipartisan support in the Senate, where Democratic and Republican leaders forged the agreement just hours earlier.

But it was able to pass the Republican-dominated House shortly after 10pm only with the support of Democrats. It laid bare a rupture between moderate and more rightwing Republicans, who triggered the crisis by using their budgetary leverage in what turned out to be a futile effort to undermine Obama's signature healthcare reforms.

Only 87 House Republicans voted for the bill. The party leadership was opposed by 144 members, including Paul Ryan, the former vice-presidential candidate and a key figure in Congress.

President Barack Obama signed the spending measure into law at about 12.30 am ET on Thursday. In brief remarks at the White House shortly before the House vote, Obama said he hoped the deal would "lift the cloud of uncertainty" that had hung over the country in recent weeks.

"Once this agreement arrives on my desk, I will sign it immediately," he said in a statement delivered at the White House. "Hopefully next time it won't be in the 11th hour. We've got to get out of the habit of governing by crisis."

Minutes after the bill was passed, Sylvia Mathews Burwell, director of the Office of Management and Budget, said government employees "should expect to return to work in the morning".

On both sides of the Capitol building Republican lawmakers looked deflated after the votes, which capped a dramatic capitulation after weeks of brinkmanship with Democrats who refused to blink.

When it came, the Republican surrender was swift. With just hours to go until the deadline set by the US Treasury for extending the debt limit, House Speaker John Boehner signalled he was ready to accept a Senate-drafted peace deal that contained almost no concessions to the conservatives who had driven the country the precipice of a new financial crisis.

"We fought the good fight, but we just didn't win," Boehner told a local TV station in his hometown of Cincinnati, Ohio.

The standoff ended just after midday when Harry Reid, the Democratic majority leader, announced the deal on the the floor of the Senate. Calling for all sides to work together, he said: "Now is not the time for pointing the fingers of blame. Now is the time for reconciliation."

Mitch McConnell, the Republican minority leader, acknowledged the fight was over. "This has been a long, challenging few weeks," McConnell 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 Reid and McConnell, will fund the government until 15 January and lift the debt ceiling until 7 February, setting the stage for a possible repeat of the showdown. Both sides also agreed to a formal budget conference in an attempt to reach a longer-term deal by 13 December.

The only change to the Affordable Care Act, which Republicans had targeted when they precipitated the government shutdown, requires the Obama administration to carry out better checks on the incomes of people registering for insurance exchanges.

The bill also ensures the 800,000 federal workers who were furloughed for at least part of the shutdown will receive back pay.

By 3pm, Boehner hosted a short meeting with forlorn-looking Republicans in the House. Sources inside the meeting said he told his colleagues they had lost the fight, and was then given a tepid applause.

Several conservative members leaving the meeting conceded that the hardline Republican tactics had left them empty-handed. "We got nothing," said Thomas Massie, a Republican from Kentucky, who admitted his side had emerged with "a goose egg".

Yet for the most part they rallied behind Boehner, who had sought to appease the restive conservative element until it was no longer feasible to do so.

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 or defund the Affordable Care Act, also known as Obamacare.

Republican Senator Lindsey Graham, of South Carolina, said the Democractic party had experienced the "best two weeks" in recent history. "When we evaluate the last couple of weeks, it should be entitled the time of great lost opportunity," he said. "If we had been focused on the rollout 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."

Graham 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. He also warned of the damage that the party had inflicted on itself.

"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," he said.

Ted Cruz, the first-term Republican senator from Texas who had led the rebellion against Obamacare with a marathon 21-hour speech last month, was unrepentant. The Tea Party-backed senator was one of 18 Republicans who rebelled against their leadership to vote against the bill in the Senate.

Shortly before the Senate vote, Cruz took to the floor to urge his colleagues to vote against it. "This is a terrible deal," he said. "It embodies everything about the Washington establishment that frustrates the American people."

However he did not attempt any tactics to delay or stall the vote.

Underscoring the fault lines in the Republican party, Cruz blamed fellow senators for failing to go along with his strategy. "Unfortunately the Senate chose not to follow the House and in particular we saw real division among Senate Republicans. Had Senate Republicans united and supported House Republicans the outcome of this would have been very, very different," he said.

It was one of the worst of all possible outcomes for Republicans. None of their stated goals were achieved, and polls showed that voters overwhelmingly blamed them for the crisis. By refusing to blink, Democrats pushed Republicans to show that they would not let the US default on its debts, making it hard for the GOP to repeat its tactic.

A Louisiana Republican, Charles Boustany, said the Tea Party-backed members of the House of Representatives had put the GOP's position at risk. "This could trigger a wave of discontent that could wash out our Republican majority in the House if we're not careful – it's getting to that level," he told the National Journal.

Tim Huelskamp, a member of Tea Party congressional caucus, told the Guardian the divisive vote in the House would help identify the moderates in his party which he said had “given up the fight”.

“People back at home realise not all Republicans are conservatives,” he said. “And some Republicans are anti-conservative.”

Senator Mike Lee, a Republican ally of Cruz, struck a defiant tone on the floor, perhaps indicating more trouble ahead “The media keeps asking: was it worth it? My answer is it is always worth it to do the right thing,” he said, adding: “This is not over.”

That view was not shared at the White House. As he left the lectern after his Wednesday night press briefing, the president was asked by a journalist whether the crisis would happen all over again in a few months. Speaking over his shoulder, Obama replied: “No.”