After days of rancor and uncertainty on Capitol Hill, the Senate has passed a massive spending bill, formally averting a government shutdown and sending the $1.1 trillion measure to the president's desk.
The vote, which pitted both parties' establishment against its more populist wings, was 56-40.
Twenty-one Democrats and 19 Republicans voted against the measure.
The bill funds most of the government until September 2015, although it sets up another battle over the funding of the Department of Homeland Security early next year. Republicans who opposed the legislation said it did not do enough to curb the president's immigration policy; some Democrats, including Sen. Elizabeth Warren of Massachusetts, objected to the insertion of language rolling back Wall Street reforms.
The vote came after Republican Sens. Ted Cruz of Texas and Mike Lee of Utah forced a rare weekend session by demanding that the Senate vote on a measure objecting to the president's recent executive action on immigration.
Under a deal struck late Saturday night, Cruz ultimately won a vote on a "constitutional point of order" to determine whether or not Obama's executive actions on immigration are outside the boundaries of the president's authority. But that measure failed 74-22, with many Republicans using their vote to express disapproval of the way Cruz pushed for the vote.
In a statement prior to the vote, Cruz said it would "allow Republicans to also show they are committed to ending Obama's amnesty once and for all in the next Congress." And he said that the measure will force Democrats to side with the president on an unpopular policy.
"They will show America whether they stand with a lawless President, who is defying the will of the voters or the millions of Americans who want a safe and legal immigration system," he said of Democrats.
Senate Majority Leader Harry Reid responded by saying that Cruz is "wrong, wrong, wrong."
"The constitutional objection is completely without merit and it should be rejected," he said.
The weekend session prompted open complaints from Cruz and Lee's fellow Republicans, who said that the gumming up of Senate action merely delayed the inevitable.
"I don't see any end goal that can be won, other than irritating people," Sen. Orrin Hatch, R-Utah, told reporters.
And some grumbled that the strategy backfired because it gave Democrats extra time to push through presidential nominations. Senate Democratic aides said that the Saturday session would result in the ultimate confirmation of 24 additional nominees by the end of the year.
"What Cruz did aided and abetted us getting nominations," Sen Chuck Schumer, D-NY, told reporters earlier today, "Cruz, in one fell swoop has taken all the hard work of Mitch McConnell & John Boehner trying to show that they can govern away."
Unlike the budget battle of 2013, Democrats as well as Republicans have threatened the successful passage of the spending bill this year. The legislation narrowly passed the House after Democrats objected to language that loosens financial regulations.
"This is certainly a very poor way to end the year, and will only confirm the public's already low opinion of Congress," Republican Sen. Susan Collins said Saturday.
NBC's Kelly O'Donnell contributed.