The Senate passed a $1.1 trillion spending bill late Saturday that funds the government through next September, averting a partial government shutdown and sending the measure to President Obama's desk.

The Senate voted 56-40 for the long-term funding bill, the main item left on Congress' year-end agenda. The measure provides money for nearly the entire government through the end of the current budget year Sept. 30. The sole exception is the Department of Homeland Security, which is funded only until Feb. 27.

Hours earlier, the Senate had approved a short-term bill funding the federal government through Wednesday night, easing concerns of a potential partial government shutdown. The stopgap bill, which passed by a voice vote, bought lawmakers more time to comb through the separate $1.1 trillion long-term funding bill. 

The votes capped a day of intrigue in the upper chamber of Congress that included a failed, largely symbolic Republican challenge to the Obama administration's new immigration policy, while Democrats launched a drive to confirm two dozen of Obama's stalled nominees to the federal bench and administration posts before their majority expires at year's end.

Several Republicans blamed tea party-backed Texas Sen. Ted Cruz for giving the outgoing majority party an opportunity to seek approval for presidential appointees, including some that are long-stalled.

"I've seen this movie before, and I wouldn't pay money to see it again," said Sen. Johnny Isakson, R-Ga., recalling Cruz' leading role a year ago in events precipitating a 16-day partial government shutdown that briefly sent GOP poll ratings plummeting.

Asked if Cruz had created an opening for the Democrats, Sen. Orrin Hatch, R-Utah said, "I wish you hadn't pointed that out," adding "You should have an end goal in sight if you're going to do these types of things and I don't see an end goal other than irritating a lot of people."

It was Cruz who pushed the Senate to cast its first vote on the administration's policy of suspending the threat of deportation for an estimated four million immigrants living in the country illegally. He lost his attempt Saturday night, 74-22, with 23 of the 45 GOP senators voting down the Texan's point of order.

"If you believe President Obama's amnesty is unconstitutional, vote yes. If you believe President Obama's amnesty is consistent with the Constitution, vote no," he said.

Senate Majority Leader Harry Reid rebutted instantly, saying Cruz was "wrong, wrong, wrong on several counts," and even Republicans who oppose Obama's policy abandoned the Texan.

The spending bill, which cleared the House on Thursday, was the main item left on Congress' year-end agenda, and exposed fissures within both political parties in both houses. The controversial package was opposed by conservative Republicans such as Cruz for not challenging Obama's immigration measures, as well as by leading liberals such as House Democratic Leader Nancy Pelosi, D-Calif. and Sen. Elizabeth Warren, D-Mass. who have criticized the bill for repealing banking regulation.

Despite the opposition from liberals, the package won a personal endorsement from Obama and was brought before the Senate. The legislation locks in spending levels negotiated in recent years between Republicans and Democrats, and includes a number of provisions that reflect the priorities of one party or the other, from the environment to abortion to the legalization of marijuana in the District of Columbia.

Despite protests from the liberal wing of the Democratic Party, more than 70 House Democrats supported the measure, and Obama made clear that he didn't view the provision as a deal-killer.  Obama acknowledged that the measure has "a bunch of provisions in this bill that I really do not like," and said the bill flows from "the divided government that the American people voted for."

Obama has sided with old-school pragmatists in his party like Reid, but split from liberals such as Pelosi and Warren. Warren blasted the measure in a Senate speech for the third straight day, saying it was a payoff to Citigroup, whose lobbyists helped write a provision that significantly weakens new regulations on derivatives trading by Wall Street banks.

"Enough is enough. Washington already works really well for the billionaires and the big corporations and the lawyers and the lobbyists," Warren said. "But what about the families who lost their homes or their jobs or their retirement savings the last time Citi bet big on derivatives and lost?"

Another provision loathed by many Democrats -- though backed by the Democratic National Committee -- raises the amount of money that wealthy donors may contribute to political parties for national conventions, election recounts and headquarters buildings.

Democrats will lose control of the Senate in January because of heavy losses in midterm elections last month and will go deeper into a House minority than at any time in nearly 70 years.

Fox News' Chad Pergram and The Associated Press contributed to this report.