Running short of cash, Treasury won an immediate reprieve of $400 billion in new borrowing authority Tuesday with the enactment of a hotly contested debt and deficit-reduction agreement hammered out between Republicans and the White House on Sunday night.

President Barack Obama, not hiding his frustration, quickly signed the measure sent to him by Congress after a final 74-26 Senate roll call, capping an unprecedented hard-edged political struggle that had pushed the nation to the brink of default.

Indeed, the stakes were far larger than with the April shutdown fight, and more than any single event this year, the debt battle captured all the power — and critics would say extreme risk-taking — of the anti-government backlash that fueled the GOP’s gains in the 2010 elections.

The timing makes it a gamble too with the faltering recovery. Most of the promised $2.1 trillion in deficit reduction will take place in the out years, but discretionary spending will continue to fall in 2012 and the same Congressional Budget Office — which scored the cuts — will soon issue its August economic update, which could show slower growth.

House Speaker John Boehner has argued the opposite: More aggressively addressing deficits “will in fact provide more confidence for employers in America, the people we expect to reinvest in our economy and create jobs.” But a sell-off Tuesday on Wall Street sent the Dow down 265 points, reflecting growing pessimism about the economic outlook. And as lawmakers left for the summer recess, Democrats vowed to turn the agenda more toward job creation when they return.

“We crossed a bridge,” said House Minority Leader Nancy Pelosi (D-Calif.) “Enough talk about the debt. We have to talk about jobs.”

Obama signaled as much in a Rose Garden appearance after the Senate vote. Extending his 2-percentage-point cut in payroll taxes remains a priority and the appropriations bargain, in fact, gives him a leg up in bargaining with House Republicans over investments billed as part of his jobs agenda.

“It was a long and contentious debate” Obama said of the debt fight. “And I want to thank the American people for keeping up the pressure on their elected officials to put politics aside and work together.

“Voters may have chosen divided government, but they sure didn’t vote for dysfunctional government. They want us to solve problems. They want us to get this economy growing and adding jobs.”

Senate Minority Leader Mitch McConnell (R-Ky.), who played a central role in crafting the final compromise with Vice President Joe Biden, was more upbeat.

“It may have been messy. It might have appeared to some like their government wasn’t working,” McConnell told fellow senators minutes before the vote. “But, in fact, the opposite was true. The push and pull Americans saw in Washington these past few weeks was not gridlock. It was the will of the people working itself out in a political system that was never meant to be pretty. … It was a debate that Washington needed to have.”

Pretty it wasn’t — late-night weekend sessions, insults, backstabbing among leaders and multiple press conferences by a besieged president all played out in the hottest July in Washington on record.

Down to the end, Senate Minority Whip Jon Kyl angrily protested the defense spending cuts assumed in the package, but he and other top Republicans fell in line behind McConnell, who won a solid majority, 28 votes, from his caucus together with 45 Democrats and independent Sen. Joe Lieberman of Connecticut.

“This problem wasn’t created overnight, and it won’t be solved overnight,” said Sen. Lamar Alexander (R-Tenn.), who turned to Amtrak to capture the mood. “If I were sitting at Union Station trying to catch a train to New York City, and someone offered me a ticket to Baltimore or Philadelphia, I’d take it and then find a way to get to New York from there.”

The debt ceiling increments have their own train schedule.

The $400 billion, which became available immediately upon a certification submitted by Obama to Congress on Tuesday afternoon, will first help Treasury backfill some of the estimated $237 billion in “extraordinary measures” it has taken since the spring to keep itself afloat. But auctions for new borrowing could be announced as early as Wednesday.

A second $500 billion adjustment in the debt ceiling will then be needed this fall but is all but guaranteed under the procedures agreed to by the Republican leadership. And to get through 2012, Obama will be able to tap an additional $1.2 trillion to $1.5 trillion, depending on the success or failure of a new joint committee assigned to report a major deficit-reduction bill by late November.

The first two increments, totaling $900 billion, are offset by $917 billion in 10-year savings achieved by cutting annual appropriations to $1.043 trillion in 2012 — nearly $100 billion below Obama’s February budget — and then slowing the rate of future growth to a fraction of inflation.

The second debt tranche would be offset as well under the agreement, either through the joint committee’s work product or automatic across-the-board cuts that would most heavily hit defense spending.

The $1.2 trillion is the minimum standard set and represents a rough approximation of the maximum savings that Republicans were assuming when talks broke off between the president and Boehner on July 22.

Days later, Boehner upped the target as high as $1.8 trillion — the first of several moves the speaker made to try to win over conservatives in his caucus. He ultimately succeeded in narrowly passing a House bill, but precious time was lost in the process, and in accepting the $1.2 trillion standard, he has essentially moved closer to his prior understandings with the White House.

Even so, getting to $1.2 trillion won’t be easy for the joint committee. Obama made concessions to Boehner in the context of expecting tax reform and that some additional revenues would be part of the mix. If the joint committee stalemates on that question — which seems likely now — the panel could come up with less, perhaps $1 trillion for example, and then rely on the across-the-board cuts or sequester to complete the job with another $200 billion in savings.

McConnell, the chief Republican architect of the compromise, has been adamant that no tax increases will come out of the joint committee. And he and Boehner have effective control given that they will hand-pick six of the 12 members. That said, the defense lobby — a strong force still among Republicans —will most feel the impact of any sequester, and the industry is already being squeezed by the revised appropriations targets set for 2012 and 2013. And a second force is the commodity lobby, which thrives on futures trading and is already calculating whether it would fare better under across-the-board cuts to farm programs rather than submit to what could very likely be bigger reductions ordered by the joint committee.