What's in US debt ceiling deal and who won?
Congress has approved a deal to raise the government's borrowing limit and prevent a potentially catastrophic default on US debt repayments.
The agreement passed the Senate on Thursday, a day after it passed the House of Representatives.
Once signed into law by President Joe Biden, it will allow the federal government to borrow money until after the next presidential election in November 2024.
Here are the highlights from the package, with analysis by BBC North America correspondent Nomia Iqbal.
Debt ceiling suspended until 2025
Every so often, US Congress must vote to raise or suspend the ceiling, so it can borrow more to pay its bills. Currently it is $31.4tn (£25tn).
This includes paying for federal employees, the military, Social Security and Medicare, as well as interest on the national debt and tax refunds.
But in recent years, this has become increasingly difficult, because the two sides cannot agree on the terms.
In the deal that passed through Congress, they have not raised the limit to a certain level, but suspended it entirely until 2025.
This allows them to pay their bills until that date and know that the next fight over raising the ceiling will not interfere with the presidential election.
And the rest of the world can breathe a sigh of relief once the deal is signed because a US default would have a global impact.
Caps on spending, but not defence
Republicans wanted a freeze on overall spending for 10 years, with a rise in defence spending and cuts to other budgets.
The agreement keeps non-defence spending flat next year, with a 1% rise in 2025. The implications of this belt tightening is as yet unclear.
Defence spending would increase to $886bn, which amounts to a 3% rise on this year.
There are no budget caps after 2025.
The legislation will result in $1.5tn in savings over a decade, the independent Congressional Budget Office has said.
Full funding for the medical care of military veterans would also increase, in line with what President Biden had sought.
Nomia: Both sides claim victory here. The White House says these cuts are not significant. The defence spending rise is what President Biden wanted but it's below the rate of inflation and doesn't meet the demands of the more hawkish Republicans.
Unspent Covid funds returned
With the public health emergency officially ended in May, Republicans had argued for the relief funds that were not spent to be returned.
The Congressional Budget Office has estimated this will amount to about $30bn.
Nomia: A win for Republicans. Many Democrats were concerned public health initiatives would be impacted by this, but it was easier for Biden to give up than other Republican priorities like Medicaid work requirements.
Welfare tinkered with, but no overhaul
A central demand of Republicans was to toughen up the distribution of welfare benefits by attaching strings that would mean able-bodied recipients having to work to get food and healthcare help.
Democrats were adamant this should not be on the table.
The welfare being looked at by Republicans included Medicaid (health coverage for poor Americans), the Supplemental Nutrition Assistance Program (SNAP) and Temporary Assistance for Needy Families (TANF).
Medicaid remains untouched in the deal, but the age at which work requirements are included for those on SNAP was raised from 50 to 54.
Nomia: The White House will be happy it gained exceptions to the food stamp requirements for veterans and people who are homeless but stricter work requirements overall are a win for Republicans. It proved to be a hard sell for progressive Democratic lawmakers.
Funds to enforce tax rules on wealthy Americans
A win for Democrats was securing $80bn for a decade to help the Internal Revenue Service (IRS) to enforce the tax code in last year's Inflation Reduction Act on the richest.
Nomia: The Republicans wanted to dump the $80bn in IRS funding, claiming it would be used to hire an army of agents to audit Americans - the agency said it would also be used to modernise the system. Instead - in showcasing his deal-making skills - Biden agreed to cut $20bn but divert that cash to other non-defence spending.
Easier to get energy project permits
New rules will make it easier for both fossil fuel and renewable energy projects to get licences.
This has long been advocated by Democratic Senator Joe Manchin of West Virginia.
It will basically streamline the environmental review process and potentially get projects off the ground in a faster time.
Nomia: A win and a loss for the White House. Both parties agree it takes far too long for new energy infrastructure to be built but disagree on what projects should be prioritised. Republicans want more gas pipelines and fossil fuel projects; Democrats want more clean energy. This was another red line for some progressive Democrats.
Things not in the deal
Student loan relief
Republicans had wanted the Biden plan to forgive student debt to be rescinded but it survived.
Nomia: The Biden administration's student debt case will be ultimately decided by the Supreme Court. But the bill does require the Biden administration to follow through with a plan to end the current pause - which has been in effect since the start of the pandemic - on student loan repayments by the end of summer.
Tax hikes
Democrats had targeted wealthy Americans for new tax hikes but there are no new taxes here.
Nomia: House Democrats will be fuming about this. They were already critical that the White House did not make taxes on the rich and powerful the centrepiece of their talks.
Clean energy
Republicans had wanted to repeal key provisions of the Inflation Reduction Act's clean energy and climate provisions but it was unscathed.
Nomia: A win for both - certainly as far as environmentalists are concerned. The US renewable energy industry group the American Clean Power Association said it "applauds President Joe Biden and Speaker Kevin McCarthy for prioritising national interests over partisan politics".