Barack Obama has not slept in the last week, worried about the impending debt crisis deadline, according to a White House aide. He will not be getting much sleep over the next 48 hours either, as the standoff between the Republicans and Democrats – the biggest ideological collision between the parties for decades – enters its final phase.

With only two days left to the deadline that could result in the US defaulting on its borrowing for the first time, there is still no sign of a deal. The Republican-controlled House of Representatives passed a stopgap bill by 218-210 on Friday evening. Two hours later, the Democratic-controlled Senate voted to kill it by 59-41. The Senate, keen to have a deal in place before the markets open on Monday, with the potential for huge falls in share prices, is proposing a bill of its own scheduled to go to a vote on Sunday.

The Democratic leader in the Senate, Harry Reid, speaking late on Friday about his new bill, said: "This is likely our last chance to save this nation from default."

Late last night there was an attempt to strike a compromise. Senate Republican leader Mitch McConnell and House Speaker John Boehner said that they were in serious talks with the president and were confident that the stalemate could be broken.

Although the deadline is Tuesday, damage has already been done to America's reputation. The US stock market has just had its worst week for a year and Obama, in a Gallup poll published on Friday, saw his approval ratings drop to a new low, from 45% to 40%.

The crisis is ostensibly about raising America's debt ceiling from its present $14.3 trillion (£8.7tn). But in reality the crisis is not about the ceiling but a consequence of the polarisation of US politics that began under George W Bush and hardened with the arrival of Barack Obama in the White House and the birth a few months later of the Tea Party movement.

Larry Sabato, a professor of politics at the University of Virginia, said: "This is a very unusual place in American history. No one in my field can remember circumstances like this. You have people in Congress who will not sit down and compromise. Compromise is a dirty word. But representative government is impossible without compromise. The Republicans and Democrats are voting as separate units, which they have rarely done in the US."

The crisis is being driven by a hardcore of about 20 House members affiliated to the Tea Party. They are prepared to put at risk the US's faltering economic recovery – and economies around the world – to push the Tea Party ideal of small government, in particular cutting federal spending. Martin Frost, a former Democratic congressman from Texas, writing on the Politico website, compared the Tea Party to the Taliban in its drive for ideological purity, lack of respect for tradition and unwillingness to compromise. "We now have a group of US politicians seeking political purity, who seem to have much in common with the Taliban. They are Tea Party members; and because of blind adherence to smaller government, they seem intent on risking destroying what American political leaders have constructed in more than two centuries of hard, often painful work," Frost wrote.

America, or at least the Democratic-leaning part of it, watched last week's events with horror. Polls and television street interviews reflect higher than usual anger and frustration with Washington. Political commentator Joe Klein, writing in Time magazine, caught this mood when he suggested: "I have a proposal: the Cut the Crap Act. It will have to be passed by Monday, to avoid default."

The sentiment was reflected by one of the stranger protest groups to descend on Congress last week. In the corridor outside the office of Eric Cantor, the Republican House of Representatives majority leader and one of the central figures in the drama, there were about 30 demonstrators dressed as clowns. They handed leaflets to his office and to other members of Congress calling on them to "Stop Clowning Around".

It was a cheap joke but there was serious intent on the part of the demonstrators – representatives of some of the poorest communities in America – to demand the politicians in Congress focus on what they regard as the real priorities of jobs and tackling poverty. Almost every break for television commercials seems to contain one advert either from rightwing organisations or liberal groups or unions. One funded by an alliance of unions and liberal groups says: "If Congress doesn't act by Tuesday, America won't be able to pay all of its bills."

Normally, raising America's debt ceiling is an arcane and routine matter for Congress, passing through the House of Representatives and Senate barely noticed, as it has about 140 times since the second world war. But that was before the emergence of the Tea Party movement. The Tea Party rose out of anger over the scale of federal spending, and in particular in bailing out the banks and the car industry. This populist movement expressed fury over the size of the national debt, incensed in particular that a large portion of it was held by China.

Although much of the blame for the scale of debt rests with George W Bush's wars in Iraq and Afghanistan and his tax cuts for the wealthy, Obama gets the blame too for spending billions trying to stimulate the economy.

The 2010 congressional election campaign was dominated by the Tea Party but the populist movement then appeared to fade, seemingly absorbed by the Republican mainstream. Earlier this year, in a test run for the present standoff, Republicans threatened to shut the federal government. Obama backed down and gave the Republicans spending cuts. But this was primarily a Republican campaign, not a Tea Party one.

The debt ceiling crisis is pure Tea Party. About 50 Republican members of the House are part of the Tea Party caucus but only about 20 make up the hardcore, many having arrived in Congress for the first time only in January. They view themselves as part of a transformational movement, not interested in the old ways of doing things – the bipartisan compromises of old. The hope of mainstream Republicans was that they would be able to tame and absorb the energy of the Tea Party, but it is the Tea Party that this week has dominated.

The tension in the party was highlighted in a clash between Senator John McCain, the Republican contender in the 2008 White House race and a veteran who has done deals all his political life with colleagues from the Democratic party. He described as "bizarro" the newer members and dismissed them as naive, seeing the world as a Lord of the Rings battle between good and evil. One Tea Party senators elected for the first time in November, Rand Paul, in one of the stranger exchanges of the week, responded that he was happy to regard himself as a hobbit.

The split is reflected among conservative commentators. William Kristol, the veteran rightwing commentator, speculated in a blog on the Weekly Standard website that once the crisis was over, Obama might invite the Republican hardcore to the White House to celebrate their role "in weakening the Republican party in the House and the conservative movement in the country and making it harder to defeat Obama in 2012".

Max Pappas, the vice-president of FreedomWorks, one of the bigger Tea Party organisations, responded by calling on members to ignore Kristol and described him as a "big government" conservative who "is offering more of the same bad advice he's given Republicans over the past decade".

Tea Party organisations such the Tea Party Express, Tea Party Nation, Tea Party Founding Fathers and United West offered implicit threats on Thursday that any member of the House prepared to back compromise could face a deselection challenge in next year's congressional election. The warning was reinforced by Sarah Palin, who holds sway over the movement. In a post on Facebook she wrote: "Everyone I talk to still believes in contested primaries."

On Thursday evening, this hardcore of Tea Party Republicans humiliated the Boehner by revolting over his proposed debt bill. Boehner had to abandon the vote after four hours of haggling and rewrite the plan, which was then passed on Friday. But it was an embarrassment that has undermined his position as the Republican leader in the House.

Waiting to replace him, should he falter, is his deputy Cantor, a mainstream Republican who was initially treated with suspicion by the Tea Party but who has emerged over the last week as one of its new heroes.

Cantor effectively killed off secret negotiations between Boehner and Obama on a compromise. With a deal apparently close, Cantor forced Boehner a week ago to walk away.

Sabato, who has watched Cantor for a long time, said: "He is very ambitious. He wants to be Speaker. He will not try to depose Boehner yet, not until the votes are there." Sabato added that Cantor had voted in the past for raising the debt limit and for bailouts after the 2008 economic meltdown. "He has done all the things the Tea Party hates and now he is a hero, the tough guy on spending. They are so pleased he has become hardline they have forgotten the things he did before," Sabato said.

Cantor's conversion may be partly the result of warnings from his local Tea Party movement that it was unhappy with him. What puzzles many Democrats about the intransigence of the Republican hardcore is that the Republicans have already won the argument. After the collapse of the Boehner-Obama negotiations, the Democrats in Congress dropped demands that the reduction in the national debt had to be secured through not only spending cuts but by taxes too. There are no tax rises in any of the compromise plans being circulated.

The only major division now is over timing. The Democrats want the debt ceiling raised until after the 2012 White House election while the Republicans want a return match early next year, as election campaigning gets under way.

The White House hope this weekend is that the older heads in the Senate, the Democratic leader Harry Reid and his Republican counterpart Mitch McConnell, will do a deal.

The problem is that this then has to go back to the House for a vote, possibly on Monday, hours before the debt deadline. And no one can be sure how the House is going to respond.