President Joe Biden is expected to sign legislation to raise the US debt ceiling, just two days before the US Treasury warned that the country would struggle to pay its bills.

The bipartisan measure, which was approved this week by the US house and senate, eliminates the potential for an unprecedented government default.

“Passing this budget agreement was critical. The stakes could not have been higher,” Mr Biden said from the Oval Office on Friday evening.

He added that “nothing would have been more catastrophic” than defaulting on the country’s debt.

The agreement was hashed out by Mr Biden and house speaker Kevin McCarthy, giving Republicans some of their demanded federal spending cuts but holding the line on major Democratic priorities.

It raises the debt limit until 2025 – after the 2024 presidential election – and gives legislators budget targets for the next two years in hopes of assuring fiscal stability as the political season heats up.

“No-one got everything they wanted but the American people got what they needed,” Mr Biden said, highlighting the “compromise and consensus” in the deal.

“We averted an economic crisis and an economic collapse.”

Mr Biden used the opportunity to itemize the achievements of his first term as he runs for re-election, including support for high-tech manufacturing, infrastructure investments and financial incentives for fighting climate change.

He also highlighted ways he blunted Republican efforts to roll back his agenda and achieve deeper cuts.

“We’re cutting spending and bringing deficits down at the same time,” Mr Biden said.

“We’re protecting important priorities from Social Security to Medicare to Medicaid to veterans to our transformational investments in infrastructure and clean energy.”

Even as he pledged to continue working with Republicans, Mr Biden also drew contrasts with the opposing party, particularly when it comes to raising taxes on the wealthy, something the Democratic president has sought.

It is something he suggested may need to wait until a second term.

“I’m going to be coming back,” he said. “With your help, I’m going to win.”

However, Mr Biden praised McCarthy and his negotiators for operating in good faith, and all congressional leaders for ensuring swift passage of the legislation. “They acted responsibly, and put the good of the country ahead of politics,” he said.

Overall, the 99-page bill restricts spending for the next two years and changes some policies, including imposing new work requirements for older Americans receiving food aid and greenlighting an Appalachian natural gas pipeline that many Democrats oppose.

Some environmental rules were modified to help streamline approvals for infrastructure and energy projects — a move long sought by moderates in congress.

The Congressional Budget Office estimates it could actually expand total eligibility for federal food assistance, with the elimination of work requirements for veterans, homeless people and young people leaving foster care.

The legislation also bolsters funds for defence and veterans, cuts back some new money for the Internal Revenue Service (IRS) and rejects Mr Biden’s call to roll back Trump-era tax breaks on corporations and the wealthy to help cover the nation’s deficits.

But the White House said the IRS’s plans to step up enforcement of tax laws for high-income earners and corporations would continue.

The agreement imposes an automatic overall 1% cut to spending programme if congress fails to approve its annual spending bills – a measure designed to pressure legislators of both parties to reach consensus before the end of the fiscal year in September.

In both chambers, more Democrats backed the legislation than Republicans, but both parties were critical to its passage.

In the senate, the tally was 63-36 including 46 Democrats and independents and 17 Republicans in favour, 31 Republicans along with four Democrats and one independent who caucuses with the Democrats opposed.

The vote in the House was 314-117.