In the end, 57 House Democrats voted for the bill, including two of the party's top three leaders. Democrats argued that there was too much good in the bill to scuttle it and get a worse deal next year when Republicans seize control of the Senate.
"Hold your nose and make this a better world," Rep. Sam Farr, D-Calif., said.
The measure would fund nearly every Cabinet agency through September 2015, awarding increases for health research, securities regulation, processing a backlog of rape kits and foreign aid. Republicans won cuts to the IRS and the Environmental Protection Agency. The 1,764-page bill is thick with carefully negotiated trade-offs on spending and policy "riders" on the environment, abortion and the lead content of ammunition. Democrats succeeded in getting the most politically toxic riders off the legislation.
Reid said he hopes the measure will clear the Senate for Obama's signature on Friday, though a vote may not come until the weekend.
Hours before the vote, House Democratic leader Nancy Pelosi of California delivered a rare public rebuke to Obama, saying she was "enormously disappointed" he had decided to embrace legislation that she described as an attempt at blackmail by Republicans. But Pelosi never lobbied Democrats to kill the bill, and Democratic Whip Steny Hoyer of Maryland and No. 3 Democrat Jim Clyburn of South Carolina were a steadying force in support of the measure.
Republicans, meanwhile, limited their defections to 67, mostly conservatives seeking an immediate confrontation with Obama over his moves to relax enforcement of immigration laws. Others simply refuse to vote for spending bills.
Read MoreCongress in no mood for pension bailout
But Republicans scored many wins in the legislation, seizing on new leverage gained after their sweep in last month's midterm elections.
One provision particularly galling to many Democrats would relax new bank regulations that force riskier trades in financial instruments known as derivatives into separate affiliates unprotected by deposit insurance.
The White House stated its own objections to the bank-related proposal and other portions of the bill in a written statement. Even so, officials said Obama and Vice President Joe Biden both telephoned Democrats to secure the votes needed for passage, and the president stepped away from a White House Christmas party reception line to make last-minute calls.