With a midnight deadline looming, the House of Representatives tonight voted 219-206 to pass a $1.1 trillion spending bill to keep the government running.

“My job tonight is to say thank you and Merry Christmas,” House Speaker John Boehner, R-Ohio, told lawmakers at the conclusion of the vote.

Conservatives were unhappy that the spending measure did not “defund” President Obama’s move to grant legal status to millions of illegal immigrants, while liberals were upset that the bill rolls back what they consider key Wall Street reforms.

The spending package now moves to the Senate, which will have until Saturday to vote after the House approved a “bridge” bill to allow the upper chamber more time.

A late-breaking stalemate on the spending bill had lawmakers and the White House on their toes well into the evening as they scrambled to avoid another partial shutdown of government.

After Obama, Cabinet officials and aides placed calls to skeptical Democrats, the spending bill carried with 162 Republicans and 57 Democrats little more than two hours before the deadline. Voting no were 67 Republicans and 139 Democrats. (Here is the roll call.)

In the waning hours before government funding was to run out at midnight, support for the spending measure from Democrats and Republicans alike continued to falter.

Boehner and Obama, uneasy allies, joined forces to rally votes for the 1,603-page measure, dubbed the CRomnibus because it combines what Congress calls an omnibus spending bill with a continuing resolution, or CR.

The omnibus funds most of the government through Sept. 30, the end of the fiscal year, while the continuing resolution funds the Department of Homeland Security, which includes agencies that enforce immigration laws, only through February. Congress will revisit that spending after new Republican majorities take over Jan. 6.

“It’s not a perfect bill,” said Senate Majority Leader Harry Reid, D-Nev. “But this bill is so much better than a short-term CR.”

Conservatives and liberals weren’t happy, although for different reasons.

“The Washington establishment is desperately hoping voters and lawmakers will forget about today’s ugliness, but the deception and shenanigans are different this time,” said Dan Holler, communications director for Heritage Action for America, the advocacy arm of The Heritage Foundation. Holler added:

This legislation funds President Obama’s unilateral, unlawful actions, which include granting quasi-legal status, work permits and Social Security numbers to those who are in the country illegally.

The International Brotherhood of Teamsters, a progressive union, expressed its discontent with the House for passing the CRomnibus and urged senators to vote “no” on the legislation.

“In what can only be characterized as political cowardice, 219 members of the House ignored the potential harm represented by special interest provisions in the Omnibus Appropriations Bill, and narrowly passed it in the dead of night,” Teamsters President Jim Hoffa said. He continued:

I am sure that arms were twisted and promises and threats were made in equal measure to pass a spending bill that is rife with provisions that will only prove damaging to the constituents these officials pledged to represent.

Another liberal organization, Common Cause, criticized members of the House who voted for the CRomnibus, saying they “agreed to an unprecedented sell-out of the public interest.”

“It’s a disaster, pure and simple,” the group’s president, Miles Rapoport, said.

Conservatives fought for the CRomnibus to fund the full government only until next month, thus allowing the new Congress to have a say in the appropriations process. They also contended the legislation doesn’t address the president’s executive actions to give legal status to millions of illegal immigrants.

Obama last month announced he would shield 5 million or more illegal immigrants from deportation and allow them to apply for work permits. House Republicans responded by proposing to fund the Department of Homeland Security only until Feb. 27.

The CRomnibus includes billions to pay for services for unaccompanied minors from Central America who crossed the border into the United States.

The House moved toward final passage even as it remained in recess early in the evening.

In the afternoon, the CRomnibus cleared a major procedural hurdle by the slimmest of margins.

Lawmakers gathered on the House floor to cast a vote to advance the spending bill. But as “nays” votes surpassed “yays,”  Boehner and Rep. Patrick McHenry, R-N.C., chief deputy whip, began approaching colleagues to convince them to change their votes to the affirmative.

>>> Government Spending Bill Faces Uncertain Fate

The move proved successful as Rep. Marlin Stutzman, R-Ind.,  and Rep. Kerry Bentivolio, R-Mich., cast the deciding votes in the 214-212 result by switching from “nay” to “yay.”

National Review reported that Stutzman changed his vote because House leadership promised him the CRomnibus would be pulled and replaced with a short-term continuing resolution.

In the end, 16 of 234 Republicans voted not to advance the 1,603-page spending bill.

Obama aides then sought to help Boehner secure enough votes from their respective parties to pass the legislation.

Following the close procedural vote in the afternoon, the White House issued a statement announcing Obama’s support for the CRomnibus and urging the House to pass the bill.

Obama, Vice President Joe Biden and Cabinet secretaries began calling congressional Democrats to urge them to vote for the legislation.

The White House found itself at odds with two influential Democrats — House Minority Leader Nancy Pelosi of California and Sen. Elizabeth Warren of Massachusetts.

>>> Commentary: CRomnibus Contains Troubling Inversion Language

The CRomnibus, Pelosi and Warren argued, included a provision to roll back parts of the so-called Dodd-Frank restrictions on the financial industry and allow Wall Street to “gamble with taxpayer money.” The provision, they said, “opens the door to another taxpayer-funded bailout of big banks.”

In a floor speech, Pelosi said:

I’m enormously disappointed that the White House feels that the only way they can get a bill is to go along with this. And that would be the only reason they would sign such a bill that would weaken ‘a critical component of financial system reform aimed at reducing taxpayer risk.’ Those are the words in the administration’s statement.

White House Press Secretary Josh Earnest said the president also disagrees with the provision. However, he said, it was one of many compromises made by both Republicans and Democrats.

Though Boehner said the House would avoid a government shutdown, the Obama administration called agency officials to discuss the protocol should parts of the government shut down, The Wall Street Journal reported.

These calls, though, were made out of an “abundance of caution,” as the White House didn’t expect another shutdown to occur.

Final passage required 218 votes in the House and 51 votes in the Senate.

>>> Commentary: Omnibus Would Give EPA More Money Than Obama Requested