Despite cautious optimism from both sides the US could still default on its debts, risking economic chaos around the world

A last-gasp compromise began to take shape in Congress aimed at ending the US debt deadlock that has threatened to throw the US and world economy into chaos. But, 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 limit.

The US Treasury had said that if the ceiling was not lifted by Tuesday, America would no longer have the cash needed to pay all its bills and faced the prospect of defaulting for the first time in its history. The White House has 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.

Reid told reporters he hoped a vote on the proposed legislation would be held in the Senate either late on Sunday or in the early hours of Monday morning. But a Congressional aide said the vote was more likely later on Monday.

The bill would then have to go to the House, where the vote could be a nail-biter, facing opposition from both hardline Republicans and disenchanted, left-wing Democrats who feel Barack Obama has conceded too much.

McConnell said: "We are very close. We had a good day. Both the president and vice-president called me … and they understand we have to come together."

Reid issued a statement later saying that he had signed off on the deal pending the approval of Democratic senators.

McConnell organised an evening conference call with Republican senators to discuss the details.

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

The head of the world's largest bond investor – Mohamed El-Erian of Pimco – told 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, 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 deal will raise the country's $14.3tn 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 it almost certain to come from welfare benefits. The left-leaning grassroots organisation MoveOn described it as "grotesquely immoral".

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

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

Raising the debt ceiling is normally routine but Republican members of Congress, especially a hard core allied to the Tea Party movement, have used it over the last month to hold the White House hostage.

David Plouffe, a White House adviser, told ABC it was not clear if 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 Obama in his bid for re-election next year.

The crisis has already hurt Obama, with a poll last week showing his approval ratings drop 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, and even though a debt ceiling rise is now on the cards, the country could still see its credit rating being downgraded.

The deal emerged late on Saturday after fractious public exchanges earlier in the day between Republicans and Democrats.

Pelosi, in a feisty speech on Saturday, 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, Joe Biden, the vice-president, Reid, McConnell, Boehner and Pelosi, they reached an agreement 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 on the subject. 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.