The US House of Representatives has passed a $1.1tn budget, hours before government was due to shut down at midnight on Thursday.
The Republican measure was passed by 219 votes to 206 after President Barack Obama had urged Democrats to support the budget.
It will fund most of the government until September 2015, but some areas will only receive short-term funding.
Republicans won control of both House and Senate in elections last month.
A relieved John Boehner, the Republicans’ House leader, said: “Thank you and Merry Christmas.”
Fifty-seven Democrats voted for the bill, but others were angry about the president’s call for support of the Republican bill, with Democratic House leader Nancy Pelosi saying she was “enormously disappointed” at Mr Obama’s position.
The Republicans strongly oppose President Obama’s immigration reforms and so the bill only funds the Department of Homeland Security until February.
Republicans hope that when the new Congress meets at the start of next year, they can force changes to the president’s immigration plans.
The budget bill must now be passed by the Senate and sent to the president to sign into law.
A two-day extension of government funding was approved by the Senate on Thursday to give it time to pass the main budget.