It was the new Washington that started this fight: the tea party congressmen who thought that fresh eyes and pure hearts qualified them as revolutionaries. The president who believed that the way out of the problem was to think bigger.

By Saturday, they had all choked on their ambitions.

Then, over three fast-moving days, the old Washington swooped in to save them.

The deal that solved the crisis was cut, over the phone, by two men with a combined 64 years in federal office. The votes that passed that deal were cast by veterans and moderates — the survivors of “wave” elections intended to clean the place out.

The solution they produced was as time-tested as they are. And as flawed.

“It may have been messy. It might have appeared to some like their government wasn’t working,” said Senate Minority Leader Mitch McConnell (R-Ky.), one of the two who crafted the compromise. “But, in fact, the opposite was true.”

The story of how the debt-ceiling deal came together was gathered from interviews with the principal negotiators and their staff members. They described how a very public fight — carried out over weeks of news conferences, speeches and televised potshots — came to be solved in one of Washington’s most private places.

On Saturday afternoon at 1:30, McConnell picked up a phone in an ornate office in the heart of the Capitol, separated from the public by four doors, three receptionists and a police guard.

He called Vice President Biden. Each man knew the other wanted a deal.

“We didn’t have to say that to one another,” McConnell said. He had arrived in the Senate in 1985. By then, Biden had already been there 12 years. “I didn’t have to waste a lot of time telling Joe what my bottom line was.”

At that point, there were less than four days remaining before the deadline. Both parties had already tried to seize control of the crisis — and failed.

President Obama had demanded a deal that would launch a two-sided attack on the national debt: Tax revenue would go up, and spending on Medicare and Social Security would go down. He didn’t get it.

Then House Speaker John A. Boehner (R-Ohio) had tried to organize Republicans behind a proposal that would attack the debt with spending cuts only. He couldn’t. A handful of right-wingers also wanted a guarantee of a balanced-budget amendment, and they successfully defied him.

“You saw very easily how a compromise could come together” at that point, a Democratic aide said. But it hadn’t so far. After Biden and McConnell began talking, however, the details quickly took shape.

They would allow Obama to raise the debt ceiling by more than $2 trillion. They would impose about $917 billion in spending cuts. And they would create a special congressional committee to find at least $1.2 trillion more in savings — possibly by examining the tax code and expensive benefit programs such as Medicare.

They also worked out something called “the trigger.” It was the legal equivalent of a grenade that both sides held. If the two parties pulled apart — if the special committee deadlocked, or if Congress rejected its ideas — it would be triggered. And then, the idea was, they would both be very, very sorry.

To keep Democrats honest, the trigger would bring automatic cuts to some federal agency spending. To keep Republicans honest, Democrats wanted to trigger automatic cuts to the Pentagon’s budget.

By Sunday afternoon, one major sticking point remained: the amount of defense cuts in the 2012 budget.

“Oh, come on, Joe,” a Democratic aide remembered Boehner saying, objecting to the level of cuts Democrats demanded. “The president’s getting his money.”

Biden said no, the aide said, and the call ended. At the White House, aides said they would give no more: If Boehner refused, they would risk a default.

“Now, we just wait,” Obama said, according to the aide.

In the end, a compromise was reached, and the overall cuts to defense spending were diluted among other departments.

“Do we have a deal?” Obama asked Boehner in a phone call Sunday night.

At the White House, aides waited anxiously as the two men debated and interrupted each other one more time. Finally, they heard the verbal equivalent of a handshake.

“Congratulations to you, too, John,” the president said.

At that moment, a new drama opened on Capitol Hill. The hard-right Republicans who had driven the debate were now almost irrelevant — they wouldn’t support this deal, simply because it was a deal.

So the lobbying turned to the middle. The message: The bill wasn’t perfect, but there was no time left. “I realize that’s not ideal, and I apologize for it,” Boehner told Republicans in a conference call late Sunday. “But after I go through it, you’ll realize it’s pretty much the framework we’ve been operating in.”

For many, though, the message was blunter: Are you going to be the one who puts the country in default?

“Of course, the answer to that is no,” Rep. Thomas J. Rooney (R-Fla.) said Monday, after a day of that kind of lobbying. He had objected to the specter of defense cuts. “And that’s why it [stinks].”

In the end, though, the bill sold itself. Instead of making the “hard choices” that both Obama and the new Republicans said they wanted, it put many of them off. It will be up to that bipartisan committee to determine where difficult cuts will come.

It was an idea straight out of old Washington: To solve a crisis today, the bill created a crisis three months from now, when the committee’s report is due.

And each party seemed willing to believe that the committee would do what they had wanted all along.

“Some have argued the new joint select committee . . . could pave the way for tax increases,” said Rep. Dave Camp (R-Mich.). “That is not going to happen.”

Even though it could.

House Minority Leader Nancy Pelosi (D-Calif.) said, “It stops cuts in Social Security, Medicare and Medicaid.”

Even though it doesn’t.

In theory, the panel could call for changes in both the tax code and beloved federal benefits programs. Much depends on who its members are and how free they feel to negotiate.

When the House vote came, the bill passed by a wide margin. Rooney voted “yes.” And there was even less drama in the Senate on Tuesday, where the bill passed 74 to 26.

After it was all over, Obama seemed to speak for revolted Americans — the kind of people who always want a new Washington — when he described the government as “dysfunctional.”

But at the Capitol, behind the four doors and the three receptionists and the police guard, McConnell said he could imagine doing this again.

“I think some of our members may have thought the default issue was a hostage you might take a chance at shooting,” he said. “Most of us didn’t think that. What we did learn is this — it’s a hostage that’s worth ransoming. And it focuses the Congress on something that must be done.”

Read more on PostPolitics

Liberals hate the debt deal, so what?

Obama turns focus to jobs

Debt deal winners and losers

Staff writers Dan Balz, Rosalind S. Helderman and Felicia Sonmez contributed to this report.