U.S. President Joe Biden on Saturday struck a deal "in principle" with House of Representatives Speaker Kevin McCarthy to avert an unprecedented government debt default, bringing some comfort to financial markets around the world.

The federal government's debt ceiling will be raised for two years, while some of its spending will be slashed or capped over the same period, according to U.S. media reports.

House Speaker Kevin McCarthy speaks with members of the press about debt limit negotiations on May 27, 2023, on Capitol Hill in Washington. (AP/Kyodo)

The agreement was reached a day after Treasury Secretary Janet Yellen warned that the U.S. government will not be able to pay all of its bills on time if Congress does not raise the debt ceiling by June 5.

Following weeks of intense negotiations, Biden found common ground with Republican lawmakers, who control the House. He said in a statement that the deal represents "a compromise, which means not everyone gets what they want. That's the responsibility of governing."

But the Democratic president also said the deal is "good news for the American people, because it prevents what could have been a catastrophic default and would have led to an economic recession, retirement accounts devastated and millions of jobs lost."

He strongly urged that both chambers of Congress pass the agreement quickly.

The Republican speaker told reporters that he had talked to Biden twice over the phone on Saturday and reached the agreement, which contains "historic reductions in spending," adding that congressional voting is likely to take place on Wednesday.

While refraining from disclosing any specifics, McCarthy, who led House Republicans to seek drastic spending cuts, said the deal is "worthy of the American people" and that he expects to finish writing the bill by Saturday.

"We still have a lot of work to do," McCarthy said, adding that he will check the bill with the White House and speak to the president again on Sunday.

The months-long impasse over the negotiations forced Biden to cut short what would have been his weeklong trip to Asia. He was able to participate in the three-day Group of Seven summit in the Japanese city of Hiroshima but had to return home last Sunday to focus on the debt ceiling talks.

Biden had been asking Republicans to raise the $31.4 trillion debt cap with no conditions attached, claiming that the U.S. economy is robust enough to pay its bills.

To avoid an economic crisis, the two chambers must pass the bill promptly, and Biden needs to sign it into law by the so-called X date. But the prospects of ensuring a debt default does not take place remain uncertain as opposition to the bill could come from Democrats or Republicans.

In addition to keeping spending flat for 2024 with an increase of 1 percent for 2025 in return for raising the debt limit, the major points of the agreement include additional work requirements for some recipients of government aid, according to the media reports.

The new requisites were demanded by Republicans but opposed by Democrats, with McCarthy praising the deal as having "consequential reforms that will lift people out of poverty into the workforce."

Republicans, meanwhile, were seeking to limit spending on everything apart from veteran and defense-related areas for more than 2 years.