The Democratic-controlled Senate’s bipartisan compromise won approval by 81 votes to 18.
The deal was then passed by 285-144 in the House of Representatives, despite much criticism from the Republican rank and file.
It came hours before the deadline to raise the $16.7tn (£10.5tn) limit was expected to expire.
The bill extended the treasury’s borrowing authority until 7 February.
It also funds the government to 15 January, reopening closed federal agencies and bringing hundreds of thousands of employees back to work.
President Barack Obama (pictured) signed the bill into law early on Thursday morning, ending fears of a US default.
However, the situation is far from resolved – although markets across the US closed higher, the Democrats and Republicans are still divided over the budget.