The US Congress has approved a deal to lift the country's borrowing limit, days before the world's largest economy is due to default on its debt.
The bipartisan measure sped through the Senate by a vote of 63-36, a day after it cleared the US House of Representatives.
President Joe Biden has said he will enact the measure into law.
His signature on the bill will spare the US from a catastrophic default on its $31.4tn (£25tn) debt.
The country is forecast to overshoot its current debt ceiling on Monday 5 June.
A default would limit the government's ability to borrow more money or pay all of its bills. It would also threaten to wreak havoc overseas, affecting prices and mortgage rates in other countries.
In Thursday night's session, the bill passed with support from 44 Democrats and 17 Republicans, plus two independents.
Sixty votes were required to approve the measure in a 100-seat chamber that Democrats only narrowly control.
Thirty-one Republicans were opposed, including a member of the party's leadership in the chamber, John Barrasso.
Among the four Democrats who voted against were left-wing senators Bernie Sanders, John Fetterman and Elizabeth Warren.
Senators first proposed 11 amendments to the debt ceiling bill, but they were all rejected in quick order, paving the way for a final vote.
If a single one of the amendments had passed, the whole bill would have had to be sent back to the House, leaving little time to ensure final passage of the measure before the US fell off a fiscal cliff.
"America can breathe a sigh of relief, a sigh of relief because in this process we are avoiding default," Democratic Majority leader Chuck Schumer told the Senate.
In a rare display of bipartisanship, Senate Republican leader Mitch McConnell told reporters he would be "proud to support it without delay".
The deal easily cleared the House on Wednesday evening by a vote of 314-117. Some 165 Democrats joined 149 Republicans in approving it by the required simple majority.
With Republicans in control of the lower chamber of Congress and Democrats holding sway in the Senate and White House, a deal proved elusive for weeks until Mr Biden and House Speaker Kevin McCarthy inked a compromise last weekend.
The agreement suspends the debt ceiling, the spending limit set by Congress that determines how much money the government can borrow, until 1 January 2025.
The legislation will result in $1.5tn in savings over a decade, the independent Congressional Budget Office said on Tuesday.
The contents of the bill drew objections from both right-wing Republicans and left-wing Democrats, but there were more than enough political centrists in both parties to get it over the line.
The last time the US came this close to overshooting its debt ceiling, in 2011, the credit agency Standard & Poor's downgraded the country's rating, a move that has yet to be reversed.
Ahead of the Senate vote, US stock markets made gains, with the Dow closing 0.5% higher. The broader S&P 500 index rose by 1% and the tech-heavy Nasdaq ended the day 1.3% higher.