WASHINGTON -- U.S. President Joe Biden celebrated a "crisis averted" in his first speech to the nation from the Oval Office Friday evening, ready to sign a budget agreement that eliminates the potential for an unprecedented government default that he said would have been catastrophic for the U.S. and global economies.

The bipartisan measure was approved by the Senate late Thursday night after passing the House in yet another late session the night before. Biden is set to sign it at the White House on Saturday with just two days to spare until the Treasury Department has warned the U.S. wouldn't be able to meet its obligations.

"Passing this budget agreement was critical. The stakes could not have been higher," Biden said. "Nothing would have been more catastrophic," he said, than defaulting on the country's debt.

The agreement was hashed out by 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," Biden said, highlighting the "compromise and consensus" in the deal. "We averted an economic crisis and an economic collapse."

Biden used the opportunity to itemize the achievements of his first term as he runs for reelection, including support for high-tech manufacturing, infrastructure investments and financial incentives for fighting climate change -- while at the same time highlighting how he forestalled steeper spending cuts pushed by the GOP that he said would have rolled back his agenda.

"We're cutting spending and bringing deficits down at the same time," 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, 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's 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."

Biden's remarks were the most detailed comments from the Democratic president on the compromise he and his staff negotiated. He largely remained quiet publicly during the high-stakes talks, a decision that frustrated some members of his party but was intended to give space for both sides to reach a deal and for lawmakers to vote it to his desk.

White House press secretary Karine Jean-Pierre said Friday that Biden was using the occasion to deliver his first address to the nation from behind the Resolute Desk in the Oval Office because "he just wanted to make sure that the American people understood how important it was to get this done, how important it was to do this in a bipartisan way."

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.

And he made a renewed pitch for his governing style, which he described as less shouting and lower temperatures after four years of President Donald Trump.

"I know bipartisanship is hard," he said. "And unity is hard. But we can never stop trying."

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 Internal Revenue Service and rejects 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' plans to step up enforcement of tax laws for high-income earners and corporations would continue.

The agreement also imposes an automatic overall 1% cut to spending programs if Congress fails approve its annual spending bills -- a measure designed to pressure lawmakers 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.

------

AP Congressional Correspondent Lisa Mascaro contributed to this report.