In a surprise, the House overwhelmingly approved the measure in a 316-113 vote. The Senate later backed the bill 65-33, sending it to President Barack Obama, who signed it into law Friday afternoon.
The lopsided House vote was a major victory for new Speaker Paul Ryan. He secured the votes of 150 Republicans -- a majority of the House GOP conference. Ryan's predecessor, John Boehner, rarely got that kind of backing from Republicans on a spending bill when ran the House.
Obama called Ryan after the vote to thank him "for helping government work," the speaker said. The president also invited Ryan to join him for a meal at the White House in the new year.
Kansas GOP Rep. Tim Huelskamp, a member of the conservative House Freedom Caucus, told CNN he believes Republicans wanted to give Ryan a fresh start.
The vote is not "a function of the spending bill but ... a courtesy to the new speaker," said Huelskamp, who voted against the bill.
He warned that Republicans who supported the measure will get grief from constituents when they go home. Huelskamp also argued the bill is a "Christmas present to Donald Trump" because it represents another example of the Republican establishment cutting deals with Democrats.
Indeed, passage was a win for House Democratic Leader Nancy Pelosi who took several last minute steps to assuage liberals in her caucus who threatened to torpedo the bill over concerns about lifting the ban on exporting oil in the bill and the lack of a bankruptcy provision in the bill to help fiscally stressed Puerto Rico.
Incensed members of the Congressional Hispanic Caucus and Congressional Black Caucus seized on the Puerto Rico and oil export issue issues in the past two days and argued the bill should be defeated. Their votes for the bill were key because it was believed the GOP could provide only about 100 votes for the deal so Democrats would need to provide the rest to make it to the necessary 218 vote threshold.
Pelosi got commitments from congressional leaders and the White House to address Puerto Rico early next year. She and her top lieutenants worked behind the scenes to get the bill passed.
They told Democrats at a closed-door meeting that while they aren't thrilled with the deal, on balance there are still things in it worth supporting, such as a health program for 9/11 first responders and increased spending for other key domestic priorities. They warned if the bill didn't pass, Republicans would still end up getting the tax cuts that were negotiated alongside the spending bill, and Democrats would be short-changing a host of programs they have fought to give more resources.
Conservatives complained that Ryan didn't include some items they wanted, such as new restrictions on Syrian refugees coming into the country or limits on federal dollars for Planned Parenthood. But the speaker argued that in divided government, there was a limit to what Democrats could accept and said it contained "some big wins for the country, whether it's lifting the oil export ban, increasing military spending or renewing health care for the 9/11 first responders."
Ryan repeatedly stressed he doesn't like rolling up all the spending bills, along with a myriad of policy provisions, into one measure. And he made clear he believes the House is simply finishing the work left by Boehner.
"We inherited a process, a cake that was pretty much more than half-baked," Ryan said Thursday.