WASHINGTON — The House approved a sweeping $1.1 trillion spending bill Thursday night, with less than three hours before a midnight deadline to fund the government, after a day of arm-twisting, uncertainty, and unlikely alliances.
The Senate is expected to begin debating the measure Friday, and leaders from both parties expect it to pass with far less drama. President Obama has indicated he will sign it.
To keep the government from shutting down before the Senate votes, which could take one or more days, the House and Senate approved a two-day stopgap measure late Thursday that will fund the government at current levels.
The threat of a shutdown and the public exercise of dysfunction had a familiar ring as the clock ticked toward midnight. Tense negotiations over keeping the government open have become a ritual in recent years, as lawmakers have used the budget to wage larger policy battles.
But Thursday's nail-biter was unusual.
The struggle to approve the measure lingered through the day, with a scheduled vote on the measure delayed for seven hours, because of an unlikely battle that pitted the White House and Republicans against Senator Elizabeth Warren of Massachusetts and House minority leader Nancy Pelosi.
The House's 219-206 vote was a defeat for Warren and other liberals. Fifty-seven Democrats supported the measure, while 67 Republicans opposed it. Eight of the nine members of the Massachusetts delegation voted no, the exception being Representative Michael Capuano of Somerville, who did not vote.
The fight that divided Democrats among themselves threatened to unravel the comprehensive $1.1 trillion spending deal that would give more financial certainty to thousands of government programs until the end of September.
The bill's supporters cited it as a bipartisan achievement that they say maintains a strong military, helps fight the Ebola outbreak in Africa, cuts IRS funding, and provides money for popular local transportation projects such as the Green Line extension in Somerville and Medford.
"With a bipartisan vote, the House has passed a responsible bill to keep the government running and address the American people's priorities," House Speaker John Boehner said in a statement released after the vote.
Warren and other liberal Democrats opposed the budget deal — which was negotiated by a group of House Republicans and Senate Democrats — chiefly because it included a provision that altered Wall Street regulations known as Dodd-Frank that were crafted to avoid a financial crisis like the one that threatened large financial institutions in 2008.
"When the next bailout comes, a lot of people will look back at this vote to see who is responsible for putting the government back on the hook to bail out Wall Street," Warren said on the Senate floor Thursday afternoon as she tried to rally support for stripping the language from the bill.
The day's chaos underscored the potential risk and reward for Warren, a liberal leader who could be viewed as an obstructionist for trying to scuttle a bipartisan deal or celebrated by her admirers for fighting Wall Street.
"The biggest threat that we face is gridlock, deadlock, and the way that we paralyze ourselves by making the perfect the enemy of the good," said Senator Barbara Mikulski, a Maryland Democrat who negotiated the bill.
Boehner defended the provision opposed by Warren. It would remove a rule that requires big banks to move certain risky financial investments into separate units, so that they are not backed by federal government insurance or given other protections.
"Democrats have supported this provision in the past," Boehner said. "It was agreed to in this bill in a bipartisan, bicameral agreement."
The 1,603-page bill's detractors found disparate reasons to oppose it. Representative Stephen Lynch, a South Boston Democrat, said he opposed it not only because of the Dodd-Frank change, but also because it allowed corporations to cut pensions.
He and others also opposed a campaign spending provision that would increase the statutory limit one person can give to national political party committees from $97,200 a year to $777,600.
Pelosi said she would vote against the bill but did not insist that her fellow Democrats join her. She criticized Obama for offering his support. Obama, in his statement, expressed disappointment with the Dodd-Frank and campaign finance provisions but still supported the overall measure.
"I'm enormously disappointed that the White House feels that the only way they can get a bill is to go along with this," Pelosi said in a sign of increasing tension among Democrats.
Conservative Republicans objected to a separate provision in the huge bill, saying it did not do enough to punish Obama for taking unilateral action to allow millions of undocumented immigrants to remain in the country.
"People don't like the president's illegal amnesty," said Representative Michele Bachmann, a Minnesota Republican.
Anger on the left and right created surprising alliances and forced GOP leaders to delay a floor vote for hours. Boehner tried to keep as many of his restive members on board as he could, while Obama and other White House officials scrambled to win over Democrats. Pelosi sent an e-mail to House Democrats, urging them to hold firm against the spending deal and "give us leverage to improve the bill."
Distressed lawmakers and aides gathered behind closed doors to strategize. Several House Democrats who emerged from a lengthy meeting Thursday evening with Denis McDonough, the White House chief of staff, did not seem to be swayed by his argument that Democrats would get a worse deal if they wait until next year, when Republicans control the Senate. They seemed only more firm in their position.
"We've got to stand up at some point on principle," said Representative Peter DeFazio, an Oregon Democrat.
House Republican leaders said Democrats would be blamed for killing a strong deal and replacing it with either a shutdown or yet another short-term extension, if the larger spending bill failed. But Democrats pushed back.
"This is blackmail," Pelosi said from the House floor.