A plan to lift the nation’s debt limit and reduce government spending cleared a crucial hurdle in the House on Monday night, as recalcitrant Republicans and disappointed Democrats rallied around a measure to avert a government default.

With Senate approval all but certain, the 269-to-161 vote in the House ended a months-long partisan stalemate that threatened to destabilize global markets and undermine the sputtering economic recovery.

The Senate vote is set for noon Tuesday. Approval would send the measure to President Obama and immediately grant the Treasury $400 billion in additional borrowing authority, just hours before a midnight deadline.

House Speaker John A. Boehner (R-Ohio) won over more than two-thirds of his caucus by assuring the lawmakers that few GOP priorities were in the line of fire and that Obama had retreated on his demand for higher taxes.

Angry Democrats largely shared that assessment. But after withholding their votes for most of the roll call, they split evenly for and against the proposal, which would cut at least $2.1 trillion from projected borrowing over the next decade without any immediate provision for new taxes.

A grueling battle that had consumed Congress for most of the spring and the summer ended with a large round of bipartisan applause shortly after 7 p.m., when the legislation secured a majority.

The lawmakers were brought to their feet again by the stunning appearance of Rep. Gabrielle Giffords (D-Ariz.), who cast her first vote — in favor of the debt deal — since she was shot in the head in early January in Tucson. The shooting prompted several weeks of soul searching on Capitol Hill about the hostile partisan rhetoric that often fills congressional debates and campaigns, a brief respite that soon passed as Congress dove into six straight months of warfare over federal budgets.

The debt plan prompted grumbling from some GOP defense hawks about proposed cuts to next year’s Pentagon budget. But Monday’s final hours were more notable for the cries from House liberals, who charged that the measure gave them little to support. Aside from potential military cuts, Democrats said the agreement calls on Republicans to sacrifice very few priorities, while asking Democrats to accept steep reductions in programs that benefit the middle class.

“It’s time for America to deal with its spending problem, and deal with the fact that we’ve made promises to the American people that our kids and grandkids just can’t afford,” Boehner said at a valedictory news conference 31 / 2 hours before he gaveled the vote shut.

Just four days after Boehner suffered a humiliating defeat when he could not pass similar legislation solely on GOP votes, the speaker still saw 66 defections from his side of the aisle.

The agreement was sealed late Sunday after weeks of acrimonious debate. If approved by the Senate, it would raise the $14.3 trillion debt limit by at least $2.1 trillion, including the immediate $400 billion released upon Obama’s signature. An additional $500 billion would come in the fall, unless two-thirds of both chambers of Congress voted to prevent it. The final increase, which would occur early next year, would provide the Treasury with sufficient borrowing power to pay the bills into early 2013.

The deal also calls for sharp cuts in agency spending — about $917 billion over the next decade, according to congressional budget analysts, starting with a $25 billion reduction in the fiscal year that will begin in October. The agreement on agency spending next year makes it far less likely that a funding dispute will shut down the government before the 2012 presidential election.

Democrats took comfort in the fact that the cuts were less severe than House Republicans approved in their budget blueprint in April. Compared with the GOP budget, the agreement provides about $44 billion more for domestic programs, including Pell grants for college — and $10 billion less for defense.

Those security cuts created a last-minute issue for Boehner, whose closest allies include the top Republicans on committees that fund the military. But at an emotional Monday morning meeting of Republicans, several longtime GOP lawmakers spoke in support of the plan, aides said.

A second stage of reductions would come later this year, with the appointment of a special committee charged with wringing at least $1.2 trillion more out of the budget over the next decade. If the committee failed to act — or if Congress did not adopt its recommendations — government spending would be cut across the board by the same amount, with the reductions split 50-50 between domestic programs and defense.

House Minority Leader Nancy Pelosi (D-Calif.) emphasized that the “trigger” would exempt programs for the poor, including Medicaid, Social Security, food stamps, and health and nutrition programs for children.

Despite those small Democratic victories, House liberals were furious about the agreement. In an interview with ABC News, Pelosi echoed the comments of Rep. Emanuel Cleaver (D-Mo.), a leading member of the Congressional Black Caucus, who called the deal a “Satan sandwich.” Pelosi added, “With some Satan fries on the side.”

A day after finalizing the deal with Senate Minority Leader Mitch McConnell (R-Ky.), Vice President Biden traveled to Capitol Hill to quell the liberal ire. First he sought to calm Senate Democrats, then he trudged into the basement of the Capitol Visitor Center to face a barrage of complaints from House Democrats that went on for more than two hours.

When he finally emerged from the meeting, Biden told reporters that he didn’t come to the Capitol “to convince. I went to explain. And lay out exactly how we got to where we were and why this is so important to the country.”

Biden told reporters that he sympathizes with Democrats.

“I would be frustrated if I were sitting there as well. That it’s been taken down to the wire like this,” he said. But he argued that in supporting the measure, they would help Obama pivot away from the budget battles and debt-limit debacle that have dominated Washington for the past seven months and renew his focus on the economy and job creation.

“If it passes and is signed into law, we will be talking about nothing come then but about jobs,” he told reporters, likening the threat of default to a “sword of Damocles” that has been dangling over the president’s head.

“We have to get this out of the way to get to the issue of growing the economy,” Biden said.

Senate Democrats seemed wearily resigned to accepting the agreement.

“I just think we could not let the country go over a financial cliff,” Sen. Amy Klobuchar (Minn.) said after the meeting. “We had to make a decision here. We were not just in the ninth inning, we were in the bottom of the ninth and there were no extra innings and it was time to get this done.”

But House Democrats were, as a group, angry, saying that the democratic process had been overtaken by right-wing ideologues. Many Democrats complained that the White House had ignored them in its negotiations with Republicans. And many were furious that the final deal would do too little to protect programs for the poor, in their view, and would not live up to Obama’s pledge to have a “balanced” approach — higher tax revenue from corporations and the wealthy.

“We can try to sugarcoat it all we want. But the bottom line is, when Republicans started this debate, they said under no circumstances would they vote for any kind of compromise that had tax increases. And that’s just what they got,” said Rep. Eliot L. Engel (D-N.Y.).

Engel said Democrats were satisfied to avoid the government’s first default, which could have led to higher interest rates and sent shock waves through financial markets.

“But if you had told me that this would be the package a month ago, I would have asked you what you had been smoking,” he said.

For Republicans, the vote allowed them to achieve most of the spending cuts they had sought earlier this year in the budget drafted by House Budget Committee Chairman Paul Ryan (R-Wis.).

“Did we get 100 percent of the discretionary cuts we were looking for? No, we got two-thirds,” Ryan said at the news conference with Boehner and other GOP leaders. “That’s better than zero. I’ll take two-thirds in my direction than anything else, and we’re going in our direction.”

The dispute over the debt ceiling — which began with Treasury Secretary Timothy F. Geithner’s Jan. 6 letter to Boehner notifying him that the limit would soon be reached — has been so prolonged and come so close to the brink that there may have been no political victors.

The public recoiled at the legislative process. In a Washington Post-ABC News poll conducted before Obama announced the deal late Sunday, 37 percent say they now see the president less favorably, about double the number (18 percent) who viewed him in a more positive light. Boehner suffered a sharper drop in his image, with about three times as many saying their opinion of him has deteriorated rather than improved over the past few weeks (34 percent less favorable; 11 percent more so).

Nearly three-quarters of Americans offered a negative word to describe how they viewed the budget negotiations. The top words were “ridiculous,” “disgusting” and “stupid.” Overall, nearly three-quarters of Americans offered a negative word.

Just 2 percent had anything nice to say.

Polling director Jon Cohen contributed to this report.