WASHINGTON — Observing a rare cease-fire in their battles with President Donald Trump, the Democrat-controlled House on Thursday easily passed bipartisan debt and budget legislation to permit the Treasury to issue bonds to pay the government's bills and lock in place recent budget gains for both the Pentagon and domestic agencies.

The measure, passed by a 284-149 vote, would head off another politically dangerous government shutdown and add a measure of stability to action this fall on a $1.37 trillion slate of annual appropriations bills.

The hard-won agreement between the administration and Democratic House Speaker Nancy Pelosi lifts the limit on the government's $22 trillion debt for two years and averts the risk of the Pentagon and domestic agencies from being hit with $125 billion in automatic spending cuts that are all that's left of a failed 2011 budget pact. It is a welcome detente for lawmakers seeking to avoid political and economic turmoil over the possibility of a government shutdown or first federal default.

Trump took to Twitter to give the legislation his strongest endorsement yet: "House Republicans should support the TWO YEAR BUDGET AGREEMENT which greatly helps our Military and our Vets." He added in a note of encouragement, "I am totally with you!"

Democrats rallied behind the legislation, which protects domestic programs some of them have fought to protect for decades through extended stretches of GOP control of Congress. Pelosi held the vote open to make sure the tally of Democratic votes topped the 218 required to pass the measure with Democratic support alone.

House GOP conservatives, many of whom won election promising to tackle entrenched federal deficits, generally recoiled from it.

Many supporters, including the GOP leadership team, praised the bill as an imperfect but necessary result of Washington's current divided balance of power and an already overheated presidential campaign.

"The alternatives are very, very bad," said Rep. Kay Granger of Texas, the top Republican on the Appropriations Committee.

But the legislation contains no new steps to curb spending elsewhere in the budget, rankling conservatives and lawmakers alarmed by the return of $1 trillion-plus budget deficits.

"Republicans who go along with this budget deal will lose all credibility on spending. This is budget deal is ludicrous," said Jason Pye of the FreedomWorks conservative advocacy group. "The GOP has been misleading the American public on spending for years now. Yeah, they talk a great game on the campaign trail. But when it's crunch time, they fold."

Trump's active support for the measure did little to stem the tide of GOP defections. Democrats backed the bill by a 13-1 margin while less than one in three Republicans supported the Trump-backed measure.

GOP conservatives, who comprise Trump's strongest base of support in Washington, weren't critical of Trump for agreeing to the deal, even after Pelosi forced GOP negotiators to drop ambitious cuts to try to defray the bill's impact on the debt.

"You just have to understand that you lost in the negotiations and express your opinion, vote your conscience and go on," said Rep. Mark Meadows, R-N.C. "It's different when you're in the minority."

Conservative Rep. Thomas Massie, R-Ky., forced a vote to renamed the measure as "A Bill to Kick the Can Down the Road." It was easily defeated.

Pelosi was the main architect of the measure, along with Treasury Secretary Steven Mnuchin. Both sides see it as being in their interest to avert the alternative: A chaotic fall congressional session that could have pinballed from crisis to crisis.

Fights over Trump's U.S.-Mexico border wall, other immigration-related issues and spending priorities will be rejoined on follow-on spending bills this fall. The House has passed most of its bills, using far higher levels for domestic spending. Senate measures will follow this fall, with levels reflecting the accord.

Washington's arcane budget rules give each side a way to paint the deal favorably. Generally speaking, it would lock in place big increases won by both sides in a 2018 pact.

By one measure, the price tag for the legislation posts at $324 billion. But more than two-thirds of that is to simply maintain current spending levels rather than fall prey to the automatic spending cuts, known as sequestration. Another measure is $103 billion, spread over two years to Pentagon and domestic accounts, to permit modest budget hikes of 3 or 4 percentage points above current levels.

Pelosi won a little more money for domestic programs than defense, but it would be eaten up by large new costs for the census and new private sector health programs for veterans.

"We are pleased that our increase in non-defense budget actually exceeds the parity number on defense by $10 billion over the next two years," Pelosi said. "And we're pleased to be able to say that we have secured an increase of more than $100 billion in the budget cap for domestic priorities since the President took office."