A hard-won budget and debt deal easily cleared the Senate on Thursday, powered by President Donald Trump's endorsement and a bipartisan drive to cement recent spending increases for the Pentagon and domestic agencies.

The legislation passed by a 67-28 vote as Trump and his GOP allies relied on lots of Democratic votes to propel it over the finish line.

Passage marked a drama-free solution to a worrisome set of looming Washington deadlines as both allies and adversaries of the president set aside ideology in exchange for relative fiscal peace and stability. The measure, which Trump has promised to sign, would permit the government to resume borrowing to pay all its bills and would set an overall $1.37 trillion limit on agency budgets approved by Congress annually.

It also would remove the prospect of a government shutdown in October or the threat of deep automatic spending cuts.

The administration and House Speaker Nancy Pelosi, D-Calif., played strong hands in the talks that sealed the agreement last week, producing a pragmatic measure that had much for lawmakers to dislike.

Trump did step back from a possible fight over spending increases sought by liberals, and achieved his priorities on Pentagon budgets and the stock market-soothing borrowing limit. Pelosi won remarkable Democratic unity in pushing the bill through the House last week despite Democratic divides on issues such as impeachment and health care.

Democrats in the GOP-controlled Senate delivered most of their votes for the deal. Many of the more solidly conservative Republicans said it allowed for unchecked borrowing and too much spending.

The measure was an epitaph to the 2011 Budget Control Act, which came about due to a tea party-fueled battle over debt limit legislation during the run-up to President Barack Obama's re-election. That law promised more than $2 trillion in deficit cuts through 2021, including automatic spending cuts that were put in place after the failure of a so-called deficit supercommittee.

"It's not just Democrats. Republicans are also guilty. At least the big-government Republicans who will vote for this monstrous addition of debt," said Sen. Rand Paul, R-Ky. "Many of the supporters of this debt deal ran around their states for years complaining that, 'President Obama's spending too much and borrowing too much,' and these same Republicans now, the whole disingenuous lot of them, will wiggle their way to the front of the trough."

The bill would lift the debt limit for two years, into either a second Trump term or the administration of a Democratic successor.

It would reverse scheduled 10 percent cuts to defense and nondefense programs next year, at a two-year cost of more than $200 billion. An additional $100 billion over two years would add to recent gains for military readiness, combating opioids and other domestic initiatives, and would keep pace with rising costs for veterans' health care.

Follow-up legislation would fill in the line-by-line details of agency budgets when the Senate returns in September.

Those increases, assuming they are repeated year after year, promise to add $2 trillion or so to the government's $22 trillion debt.

But the measure would deliver wins to a coalition of GOP defense hawks, Democrats seeking to preserve gains in domestic accounts, and the leaders of the House and Senate Appropriations Committees.

It also would be a triumph for Senate Majority Leader Mitch McConnell, R-Ky. He initiated the negotiations and was deeply invested in bringing order and relative predictability to the budget and debt deadlines.

"We have to invest in improved readiness to help our military commanders plan for emerging challenges, in research and development to support the U.S. military of the future, and in rock-solid support for our alliance commitments," McConnell said. "This deal is an opportunity to do exactly that. This is the agreement the administration has negotiated. This is the deal the House has passed. This is the deal President Trump is waiting and eager to sign into law."