This weekend, the grind goes on with House and Senate Appropriations Committee clerks now doing the hard work of making the pieces actually fit in the new top line, just under $1.050 trillion. And having played hard-to-get, House Speaker John Boehner (R-Ohio) becomes the suitor, having to sell the deal to his young and restless Republican Conference before a floor vote next week.

Racing the clock ina long, dizzying long day of trading offers, Boehner and President Barack Obama only reached agreement hours before what would have been an unprecedented wartime shutdown of the government that threatened both men. Down to the end, Boehner was still pressing for a lower top line when Obama called him in the early evening. And the deal was only sealed in the midst of the speaker making his own presentation to fellow Republicans during a closed door party caucus.

Both men later cast the agreement as the best available, but the grueling, often distrustful process testified to how tough this legislative year will be and the immense pressure on Boehner from the right.

The administration largely succeeded in blocking the most controversial policy riders impacting the environment and abortion-rights. But the spending cut is one of the single largest in history, and a preview of what lies ahead when Republicans move their 2012 budget plan next week and fight with Obama over raising the debt ceiling in May and June.

White House Budget Director Jack Lew and the president’s chief legislative liaison, Rob Nabors, spent much the day holed up in Reid’s second floor Capitol offices, fielding an almost rapid fire succession of offers and counter offers from the House.

Lew, thrust back in the budget job at some personal sacrifice for himself, is a reminder of a gentler, more orderly time. Schooled under the late House Speaker Tip O’Neill (D-Mass.), he later served in the same budget capacity for former President Bill Clinton in the 90’s but never experienced such an anti-government mood as today.

His re-entry in this fight has been often rough, and it was apt that the younger, tougher Nabors, whom Lew mentored and who is unfailingly loyal in turn, was by his side. When Lew left Washington, Nabors stayed, rising in the House Appropriations Committee and now Obama’s team. There is a greater hardness to him and a tight-lipped style that rivals Garbo.

“I think it will be resolved,” Senate Appropriations Committee Chairman Daniel Inouye (D-Hawaii) told POLITICO late in the afternoon. Reid’s own staff were still nervous enough to peg the chances at just 50-50 going into the evening.

With a deal in hand and no time to spare, the Senate quickly adopted a one week stopgap bill to keep the government operating and buy time for processing the final package. Just minutes after midnight, the House followed suit.

Covering the last six months of this fiscal year ending Sept. 30, the agreement comes almost a full two months after the House first started the fight Feb 19 with a bill cutting $61.3 billion from spending levels at the beginning of this year and more than $100 billion from Obama’s initial budget request for 2011.

By comparison, the measure now would cut about $38 billion from this year’s spending and $78 billion from Obama’s budget – more than halfway toward the GOP in each case. But factoring in what will be a more than $4 billion increase for the Pentagon, the true cut for domestic and foreign aid programs is closer to $42 billion.

Within those confines, Obama locked in funding some of his top priorities including $700 million for “Race to the Top” education reforms and $7.6 billion for Head Start. And the administration successfully substituted billions in savings from mandatory spending programs to help relieve the pressure on discretionary appropriations.

Republicans had resisted this approach, but it paid extra dividends for Boehner in the case of reforms in the Pell Grant program to assist low income college students. The immediate savings in 2011 are about $500 million but in 2012, that could expand into a $6 billion cut from discretionary spending – the real political target for the GOP.

Altogether, the 2011 savings attributed to mandatory spending total about $17.8 billion.

In the healthcare arena, the package assumes $3.5 billion in savings from unspent performance bonus funds in the CHIP program, which helps states extend Medicaid coverage to the children of working class families. Another $2.2 billion would come from trimming back the $6 billion in loan and grant funds promised under healthcare reform last year to implement new co-op health plans – a favorite initiative of Senate Budget Committee Chairman Kent Conrad (D-N.D.).

One of the toughest fights, casting the White House as the budget cutter against reluctant Republicans, was in highway and transportation spending. But here the administration succeeded in cutting about $630 million in so-called orphan earmarks and $2.5 billion in unexpended contract authority.

Indeed, for all the political focus on the spending top-line, the tradeoffs here or the bargaining over defense vs. non-defense dollars may be just as important.

The Republican battle-cry has always been to rollback domestic appropriations to the 2008 levels at the end of the Bush administration. And in Boehner’s case, this was doubly so as the speaker sought to balance three different factions in his conference: defense Republicans, social conservatives, and tea party freshmen focused most of the bottom line savings.

Mindful of this, Democrats used the defense number as something of a lever to get the speaker and House Appropriations Committee Chairman Hal Rogers (R-Ky.) to move on other fronts. At one point, the proposed Pentagon budget number was as low as $511 billion—well below what Obama’s own Defense Secretary Robert Gates would want. And as Democrats and the White House have moved higher, Rogers was more willing to accept one of their goals: savings from mandatory spending programs to relieve the pressure on domestic appropriations.

By late Friday, the Democrats had moved up to $514 billion –a $5.3 billion increase over current spending – but were also asking for an across-the-board government-wide percentage cut that would not exempt defense. This proved too much for the GOP, fearful of losing Republicans on the House Armed Services Committee, and the final bargain sets defense at $513 billion and exempts it from an across-the-board cut intended to save an estimated $1.14 billion.

In the case of the State Department and foreign aid, a second safety valve is to shift costs into the same overseas contingency operations (OCO) account used to fund military operations in Afghanistan and Iraq.

Much as foreign aid is an easy target in today’s political climate, Republicans like South Carolina Sen. Lindsey Graham argue that some flexibility should be allowed for State’s war-related costs. And the framework being negotiated now is likely to allow major funding for the Pakistan Counter Insurgency Fund to be counted as part of OCO, thereby relieving some of the cost pressure on State.