The US Senate has completed congressional approval of a controversial $1.1tn (£700bn) federal budget which will now be sent to President Barack Obama to sign.
The Senate passed the bill by 56-40 in a late-night vote on Saturday.
The budget had been the subject of months of intense cross-party debate, with both Democrats and Republicans making concessions.
The bill avoids a government shutdown which could have started next week.
Republicans sought to pressurise President Obama into abandoning controversial new immigration plans by ensuring only partial funding for the Department of Homeland Security.
From January onwards, Republicans will hold a majority in both houses of Congress, which they will hope to use to block the adoption of President Obama’s amnesty program for some illegal immigrants.
Democrats were unhappy at the repeal of financial regulation clauses. But others said it was hard to vote against the bill considering its scope and the fact the Democrats will be in a worse position to negotiate next year.
The bill had already cleared the House of Representatives in a close and contentious vote on Thursday.
With the prospect of a government shutdown fast approaching, Congress twice passed emergency funding bills to buy more time for an agreement, with the latest extension coming earlier on Saturday.