With a last-minute budget deal, Congress averted a federal government shutdown Friday night and created provisions to complete and process the bill next week in Washington after a strenuous week of debating the nation's future fiscal responsibilities.

The Friday deal included $38.5 billion in spending cuts while prolonging debates on policy matters such as Planned Parenthood. Fiscal measures such as raising the debt ceiling and the 2012 budget are expected to come into play in the upcoming weeks.

President Obama signed a short term spending deal Saturday that allows the government to pay for federal operations through next Friday, where the 2011 budget is expected to be signed off by lawmakers.

The White House posted a statement Saturday on their web site explaining their perspective of the budget cuts.

"Today, small businesses will no longer worry or have to wait on a loan to open or expand their business, families will receive the mortgages they applied for, and hundreds of thousands of government workers, including our brave men and women in uniform, will continue to receive paychecks on time," the statement read. "We avoided deep cuts in international programs that, among other things, threaten our transition out of Iraq."

But to reach the spending agreement, the two sides followed a twisting path, according to accounts offered Friday and Saturday by Obama administration, House GOP and Senate Democratic aides who spoke on condition of anonymity to describe confidential talks.

The path toward a spending collision began in February, when the new GOP majority pushed a bill through the House over Democratic opposition, cutting this year's spending by $61 billion.

The measure included dozens of provisions curbing enforcement of environmental laws, restricting federal aid for family planning and other limitations.

That bill was rejected by the Democratic-run Senate.

With no permanent legislation in place financing federal agencies for the remaining six months of the government's fiscal year, Congress started enacting bills cutting spending and providing enough money for the government to function for just weeks at a time.

With the most recent stopgap measure expiring April 8, lawmakers worried about a public perception that they couldn't do their most basic work began looking for a way to end their impasse.

Two weeks ago, bipartisan talks started in earnest, with bargainers initially focusing on finding $33 billion in cuts. Shy of a deal and with a potential government shutdown looming, Obama invited leaders of both parties to a White House bargaining session last Tuesday.

It was clear that that session had not gone well when Boehner issued a written statement afterward saying, "We can still avoid a shutdown, but Democrats are going to need to get serious about cutting spending — and soon." Reid fired back, "I hope the Republicans do what the country needs, not what they believe the tea party wants," a reference to the influential conservatives who helped the GOP gain power in last November's elections.

Those comments set the tone for an acrimonious week.

Democrats repeatedly accused Republicans of seeking harmful spending cuts, trying to use the bill to restrict programs for women's health and constantly making new demands every time a deal seemed near. Republicans said Democrats were not serious about controlling federal spending, and accused them of holding the military hostage when the Senate refused to consider a spending-cut bill that would have financed the Pentagon for the rest of the year.

Another meeting followed Wednesday night in the White House dining room, where at one point staff was asked to leave the room, according to a senior Senate Democratic leadership aide.

Boehner wasn't proposing a specific figure for cuts, that aide said, and was pressing for the inclusion of policy restrictions that Republicans wanted.

Also at that meeting, Boehner said he would need deeper cuts than Democrats were offering, according to a House Republican aide also speaking on background. The Democratic aide said that when that meeting ended, his side's hopes for a deal had dimmed to a 1 in 5 chance of success.

Staff worked late into the night, but there was no breakthrough. Those involved included Rob Nabors, the White House legislative affairs director; Boehner chief of staff Barry Jackson; and David Krone, Reid's chief of staff.

With the clock ticking down, two more White House bargaining sessions were held Thursday among the president, Boehner and Reid.

In one of the White House meetings, a light moment occurred when the negotiators began focusing on the dozens of policy restrictions that Republicans wanted to include.

According to White House aides, Nabors had an assistant make photocopies of the long list of provisions, which ended up taking time. Boehner joked about the White House needing faster copying machines, and Obama said the copies were being mimeographed, an ancient copying technology.

A key point came Thursday night, according to the Senate Democratic staffer and White House aides.

The two sides were moving closer to agreement on the amount of spending cuts but Republicans were insisting on including curbs on federal funds for family planning programs — a demand that Democrats were just as adamantly opposing.

It was in those conversations, the Democratic aide said, that Obama and Reid said Democrats would not agree to the family planning restrictions, with the president himself saying it would not be included in any final deal. At one point, according to White House aides, Vice President Joe Biden flashed anger over the GOP's insistence on family planning restrictions.

Instead, Democrats suggested to GOP aides that when the Senate debates the spending legislation, it would vote on the restrictions Republicans want on federal aid for family planning — a suggestion that GOP staff showed some interest in.

On Friday, that formula ended up being the way that issue was resolved — even though the Senate is considered sure to vote it down.

But the two sides still hadn't reached a final spending cut figure.

After Thursday evening's White House meeting, administration and Senate Democratic aides met with House GOP staffers at the Capitol until well after midnight, the Senate Democratic aide said.

At 4:30 a.m., the White House proposed $38 billion in cuts, and Republicans made a $39 billion counter-offer shortly before noon, the Democratic aide said. Hours were spent fine-tuning the final number to $38.5 billion and working out exactly where the cuts would come from. White House aides, who spoke on condition of anonymity, said that besides being focused on the size of the cuts, they wanted to avoid slashing education, health and other administration priorities.

Helping the process, White House aides said, was a call Obama made that morning to Boehner, complaining that GOP aides were still discussing deeper cuts than the White House wanted.

When they'd finally finished their negotiation Friday night in the Capitol, Jackson, Krone and Nabors shook hands. Jackson tried telephoning Boehner, who was addressing GOP lawmakers, but the speaker's cell phone was off, according to House GOP aides.

So Jackson walked down to the basement conference room, opened the door and nodded to the speaker.

According to the aides, Boehner turned to his fellow Republicans and said, "We have a deal."

The Associated Press contributed to this report.