A $1.1 trillion (£699.9bn) spending Bill is on its way to US president Barack Obama for his signature.
The Senate voted 56-40 on Saturday for the long-term funding Bill, the main item left on Congress’ year-end agenda.
The measure provides money for nearly the entire US government through the September 30 end of the current budget year. The sole exception is the Department of Homeland Security, which is funded only until February 27.
At that point, Republicans intend to try to force Mr Obama to roll back a new policy that removes the threat of deportation from millions of immigrants living in the country illegally.
The compromise Bill had faced opposition from Democratic liberals upset about the repeal of a banking regulation and Republican conservatives unhappy that it failed to challenge the president’s immigration moves.
The fight over the Bill reflects the Republicans’ leverage after their sweeping victories in last month’s midterm elections. They will have control of the Senate and a stronger majority in the House of Representatives when the new Congress convenes in January.
Senator Ted Cruz, a favourite of the ultraconservative tea party movement, tried to challenge the spending Bill with a proposal to cut funds that could be used to implement Mr Obama’s executive actions on immigration.
That scuppered an informal bipartisan agreement to give the Senate the weekend off and gave Democratic Senate majority leader Harry Reid a chance to call an all-day Senate session on Saturday devoted almost exclusively to confirming about 20 of Mr Obama’s nominees to judicial and administration posts.