Donald Trump and congressional leaders announced on Monday that they had struck a critical debt and budget agreement. The deal amounts to an against-the-odds victory for Washington pragmatists seeking to avoid a politically dangerous tumult over the possibility of a government shutdown or the first-ever federal default.

The deal, announced by Trump on Twitter and in a statement by the Democratic House speaker, Nancy Pelosi, and the Senate Democratic leader, Chuck Schumer, will restore the government’s ability to borrow to pay its bills past next year’s elections and build upon recent large budget gains for the Pentagon and domestic agencies.

“I am pleased to announce that a deal has been struck,” Trump tweeted, saying there will be no “poison pills” added to follow-up legislation. “This was a real compromise in order to give another big victory to our Great Military and Vets!”

The agreement is on a broad outline for $1.37tn in agency spending next year and slightly more in fiscal 2021. It would mean a win for lawmakers eager to return Washington to a more predictable path amid political turmoil and polarization, defence hawks determined to cement big military increases, and Democrats seeking to protect domestic programs.

Pelosi and Schumer said the deal “will enhance our national security and invest in middle-class priorities that advance the health, financial security and well-being of the American people”. They claimed credit for winning more than $100bn worth of spending increases for domestic priorities since Trump took office.

However, the deal also comes as budget deficits are rising to $1tn levels – requiring the government to borrow a quarter for every dollar it spends – despite the thriving economy and three rounds of annual Trump budget proposals promising to crack down on the domestic programs that Pelosi is successfully defending now. It ignores warnings from deficit and debt scolds who say the nation’s fiscal future is unsustainable and will eventually drag down the economy.

“This agreement is a total abdication of fiscal responsibility by Congress and the president,” said Maya MacGuineas, the president of the Committee for a Responsible Federal Budget, a Washington advocacy group. “It may end up being the worst budget agreement in our nation’s history, proposed at a time when our fiscal conditions are already precarious.”

At issue are two separate but pressing items on Washington’s must-do agenda: increasing the debt limit to avert a first-ever default on US payments, and acting to set overall spending limits and prevent automatic spending cuts from hitting the Pentagon and domestic agencies in January.

The pact would defuse the debt limit issue for two years, meaning that Trump or his Democratic successor would not have to confront the politically difficult issue until well into 2021.

Pelosi and Schumer claimed rough parity between increases for defence and non-defence programs, but the veteran negotiator retreated on her push for a special carve-out for a newly reauthorized program for veterans utilizing private sector healthcare providers. Instead non-defence spending increases would exceed increases for the military by $10bn over the deal’s two-year duration.

In the end, nondefence appropriations would increase by $56.5bn over two years,while defence would increase by $46.5bn over those two years.

The measure would first advance through the House this week and win the Senate’s endorsement next week before Congress takes its annual August recess. Legislation to prevent a government shutdown will follow in September.