President Barack Obama announces a deal on raising the debt ceiling with Republican and Democratic congressional leaders Reuters

Barack Obama has reached an agreement with Republican and Democratic congressional leaders aimed at ending the US debt deadlock that threatened to throw the US and world economy into chaos.

However, in an address from the White House, he warned: "We are not done yet."

Although the Senate is almost certain to pass the move, it could face opposition in the House of Representatives from hardline Republicans and disenchanted, leftwing Democrats who feel Obama has conceded too much.

Obama urged members of Congress to get behind the proposed legislation, which will raise the country's debt ceiling and cut federal spending.

With time fast running out, Congress may have left it too late to meet the Tuesday deadline set by the Treasury for raising the debt ceiling above its current $14.3tn (£8.7tn) limit.

The treasury had warned that if the ceiling was not lifted by 2 August, America would no longer have the cash needed to pay all its bills, and faced the prospect of defaulting on its debts for the first time in its history.

After weeks of frustrating negotiation in Washington, Obama said: "This process has been messy and taken too long."

The White House hinted that the deadline could be extended for a few days to allow Congress to get legislation through.

The Democratic leader in the Senate, Harry Reid, said he was "cautiously optimistic" a deal would be made, a view echoed by his Republican counterpart, Mitch McConnell.

The Senate could vote on the proposed legislation on Monday; the bill would then go to the House.

McConnell has scheduled a meeting with Republican senators to discuss the details of the deal. Speaking minutes before the president, he said: "I think I can say with a high degree of confidence that there is now a framework to review that will ensure significant cuts in Washington spending. And we can assure the American people tonight that the United States of America will not for the first time in our history default on its obligations."

The deal will raise the country's debt ceiling by about $2.4tn. It sparked an immediate backlash from the left of the Democratic party because it also includes about $2.5tn in spending cuts, much of which is almost certain to come from welfare benefits.

The left-leaning grassroots organisation MoveOn described it as "grotesquely immoral".

The White House and congressional leaders were anxious to get some sort of compromise under way, fearful that uncertainty could lead to huge market falls today. The Nikkei rose after Obama's statement.

Experts warned that even if a deal was struck, the world's largest economy was likely to be stripped of its triple-A debt rating by Standard & Poor's.

Mohamed El-Erian, the head of the world's largest bond investor, Pimco, told the US broadcaster ABC: "Things that need to happen are not happening fast enough. If S&P sticks to what it said, it will downgrade."

Julian Jessop, the chief international economist at Capital Economics, said: "It looks like they will get a deal done to lift the debt ceiling but it looks like none of the numbers are going to reassure the debt rating agencies. I'm pretty sure America will lose its triple-A rating."

Such a move is likely to prompt a big jump in the cost of borrowing for the US.

The Democratic leader in the House, Nancy Pelosi, praised Obama's for his role behind the scenes in securing the compromise but said she had not seen the details yet. She was planning a meeting of House Democrats today to discuss the package, and warned there should be nothing in it that hits benefits and working-class people.

"We all may not be able to support it, or none us may be able to support it," Pelosi said.

Raising the debt ceiling is normally a routine matter, but Republican members of Congress – especially a hardcore allied to the Tea Party movement – have used the issue over the last month to hold the White House to ransom.

David Plouffe, a White House adviser, told ABC it was unclear whether there would be enough House Republicans to get a deal through.

The deal is mainly a victory for Republicans, whose mission has been to cut the huge federal spending budget and undermine Barack Obama in his bid for re-election next year. The crisis has already hurt Obama, with a poll last week showing his approval ratings having dropped from 45% to 40%. But the Republicans may be hurt, too, by their association with the Tea Party. The US's financial reputation has suffered as well, particularly over the last week.

The deal also postpones a lot of hard spending decisions by handing over negotiation to a bipartisan congressional committee. The committee is due to report by the end of November, and will have to weigh cuts in military spending against cuts in benefits.

The deal emerged after fractious public exchanges between Republicans and Democrats. Pelosi accused the Republican speaker, John Boehner, of having gone over to the "dark side" in courting Republicans allied to the Tea Party. But after a series of negotiations involving Obama, the vice-president Joe Biden, Reid, McConnell, Boehner and Pelosi, agreement was reached on the broad principles of a deal.

The Senate, which remained in session over the weekend because of the crisis, voted on a mainly procedural issue yesterday to end a Republican filibuster. In what may be a last act of defiance on this issue, Republican senators mustered enough votes to block the Democratic move. Although that seemed ominous for bipartisan co-operation, Republican senators were on course to vote for the deal.