The drama turned on a series of relationships, GOP warfare and Democratic unity. | AP Photos Anatomy of a shutdown

House Speaker John Boehner just wanted to sneak out of the White House for a smoke.

But President Barack Obama pulled him aside for a grilling. Obama wanted to know why they were in the second day of a government shutdown that the speaker had repeatedly and publicly pledged to avoid.


“John, what happened?” Obama asked, according to people briefed on the Oct. 2 conversation.

“I got overrun, that’s what happened,” Boehner said.

( WATCH: Who won the shutdown? Top 5 quotes)

It may be the most concise explanation of a chaotic, 16-day standoff that prompted the first government shutdown in nearly two decades and ended only hours before the world’s largest economy nearly exhausted its ability to pay the bills. The fiscal drama turned on a series of complicated relationships, internecine Republican warfare and rare Democratic unity.

The House Republican conference ran roughshod over Boehner, a 22-year veteran of Washington who started the fight demanding to strip funds for Obamacare but settled in the end for the reaffirmation of a minor provision already in the law.

( PHOTOS: The government reopens)

He was overtaken by Senate Minority Leader Mitch McConnell (R-Ky.), who swept in near the end to forge a bipartisan agreement, part of an attempt to shield Republicans from further damage and salvage his party’s chances of winning back the Senate next year.

A particular low point came Oct. 1 when Democrats released private emails to POLITICO aimed at making Boehner look like a hypocrite. The emails showed that Boehner had actually been deeply engaged in fixing an Obamacare glitch that would have cost lawmakers and their staff thousands of extra dollars. Hill veterans weren’t quite as shocked by the flip-flop as the utter breakdown of decorum between Senate Majority Leader Harry Reid (D-Nev.) and Boehner.

( Also on POLITICO: Obama’s latest push features a familiar strategy)

Above all, Republicans never believed Obama would hold firm on his refusal to negotiate and Democrats would maintain an unusual level of cohesion — united by a visceral desire to put the tea party in its place and an almost mama grizzly instinct to protect Obamacare.

“It was not a smart play,” McConnell said Thursday of the GOP’s Obamacare strategy. “It had no chance of success.”

Obama and Reid stuck together, emerging as the political victors. Their hard-ball tactics were designed to “break the fever” brought on by the tea party, but it also helped drive the country to the edge of default.

Republicans cycled through every option possible during the three-week standoff to save face. Their Obamacare demands devolved from repeal and defund to a delay of the individual mandate. They revived the idea of a “grand bargain” on taxes and government spending but Reid openly laughed when Boehner raised it during a White House meeting. They offered a more narrow proposal to replace the sequester cuts for two years. Then, they went back to Obamacare.

( PHOTOS: Mitch McConnell and Harry Reid’s friendship)

Nothing worked.

When things were at their worst, some Republican senators urged Vice President Joe Biden to get more involved. But he told each of them it wasn’t his call. Biden participated in meetings at the White House but Reid, still angry about the vice president’s concessions during the fiscal cliff talks last December, had shut him out of direct negotiations with lawmakers this time around.

By Wednesday, Republicans just needed a way out, agreeing to a bill that looked almost identical to what they rejected three weeks earlier: a debt-limit increase until Feb. 7, an extension of federal funding through Jan. 15 and no binding strings attached.

( Also on POLTICO: Shutdown aftermath: John Harris, Todd Purdum assess damage)

This account of the behind-the-scenes drama was drawn from dozens of interviews with key players in Congress and at the White House. The look back reveals how Republicans waged a fight on Obamacare that their leaders knew they would probably lose but pushed anyways because many in their ranks truly believed that Democrats, like they’ve done so often before, would fold — especially under the threat of an historic default on U.S. debt.

McConnell told his colleagues this week that his party should “never” be put in the same political position again.

“We fought the good fight,” Boehner told WLW radio on Wednesday. “We just didn’t win.”

( PHOTOS: John Boehner’s life and career)

The buildup to shutdown

Any hope of an easy debt limit extension was dashed in late August when Boehner promised a “whale of a fight.”

Obama and Reid got on the same page early on, agreeing during strategy sessions over the summer that they wouldn’t give up anything until Republicans renewed the debt limit and government funding.

Democrats never believed that Boehner could deliver the 217 House votes he needed to cut a deal. He could shut down the government and risk default, but because of hard-line conservatives, Boehner couldn’t pass anything. House Minority Leader Nancy Pelosi (D-Calif.) told Obama and Reid this privately, and she repeated it publicly. This belief drove the Democrats throughout the crisis: stand firm and Boehner will be forced to fold.

( WATCH: Nancy Pelosi blasts GOP for budget saga)

But they had to keep each other in check.

Reid nixed an idea in mid-September to invite the congressional leaders over to the White House for a talk. It sends the wrong message, Reid argued to Obama in a call. We shouldn’t even create the appearance of a negotiation, Reid said.

The meeting never happened.

In the House, Boehner and his leadership team ran through a spate of options — none of which his conference would accept. First, the Ohio Republican proposed keeping the debt limit and government-funding discussions separate, which Democrats were privately hoping would happen. He suggested passing a budget bill that completely funded the Affordable Care Act. A resolution would be passed alongside that defunded the law, but it could’ve been stripped out by the Senate and sent to Obama’s desk.

The proposal was dubbed the “Cantor plan,” after House Majority Leader Eric Cantor (R-Va.), who came up with the idea. Then, Boehner would’ve had Republicans fight hard on the debt ceiling, using the sequester as a bargaining chip against Obama.

( Also on POLITICO: Mitch McConnell defends deal, slams Obamacare tactics)

But that’s where Boehner miscalculated: he assumed House Republicans only wanted a show vote. Instead, they wanted so much more, determined to nullify the health care law and use a government shutdown and threat of a debt-limit default to get there.

Boehner’s rank-and-file were being egged on Sen. Ted Cruz (R-Texas), a populist freshman who was quickly gaining followers in the House as quickly as he was alienating his fellow Republicans senators.

In the run-up to the shutdown, Obama was weak politically; his Syria strategy was panned by both parties; Obamacare was suffering poor poll numbers; and Republicans thought they had him on the ropes.

( WATCH: Timeline of Ted Cruz’s Obamacare crusade)

Yet Cruz’s anti-Obamacare drive played right into Democratic hands.

“The president gets up every day and reads the newspaper and thanks God that Ted Cruz is in the United States Senate,” a Republican senator pointedly told Cruz at a closed-door meeting.

Even amiable and soft-spoken Republicans like John Boozman of Arkansas tore apart Cruz in a private GOP meeting, saying he was making GOP senators seem like they were for Obamacare when they had fought so hard to torpedo it. Boozman pointedly told Cruz he hadn’t been bullied since middle school, and he wouldn’t be bullied now.

Follow @politico

A long haul

The first week of the shutdown was marked by a series of dead-end meetings, fruitless House votes, and a total lack of communication between Boehner and Democrats.

It became clear almost from the moment the government closed Oct. 1 that it would stay that way for awhile.

The White House received intelligence from an unlikely source: Boehner’s former chief of staff Barry Jackson. A lobbyist who spoke with Jackson passed on a detailed download to top administration officials. Chief among the insights was that Boehner would have to fight right up to the Oct. 17 debt limit deadline.

Shortly after the White House meeting Oct. 2, a ragged Boehner filled in his closest allies about his talk with Obama, telling them that the president had confronted him in the room that former President George W. Bush called the “Lewinsky suite.”

Over in the Senate, tensions were running high among Republicans.

Sen. Kelly Ayotte (R-N.H.) teed off on Sen. Mike Lee (R-Utah), lambasting him for what she considered a failed strategy with no way out. Cruz arrived late, but Ayotte wanted Cruz to hear this, too. She repeated her remarks, this time directing them at Cruz, too.

“He is so incredibly immature,” sniffed one GOP senator who attended the lunch.

The lashing humbled Cruz, who began to take a quieter role in the intervening days. But he continued to push forward on strategy that Republicans had essentially left for dead.

At one point, Cruz told GOP senators that they should force votes on bills to fund individual agencies and programs, like on veterans issues.

But McConnell bluntly told Cruz that Republicans had no procedural way of doing that. In fact, he asked Laura Dove, McConnell’s chief floor expert, to explain to Cruz how Republicans were prohibited from taking such a parliamentary tactic.

Glimmers of hope

One wild card in the whole fight was Rep. Paul Ryan (R-Wis.).

The Budget Committee chairman and 2012 vice presidential nominee hardly talked to the press when he returned to Washington from the campaign trail. He was guarded as he moved through the building, but lawmakers close to him knew he was plotting something.

Ryan decided to not engage in the government funding fight — he saw it as noise without any real impact on the larger issue. The Wisconsin Republican thought it would get resolved, and then he and Boehner could negotiate with Obama on a budget deal. As long as he had sequester spending levels, Ryan told colleagues on the House floor, he thought he could complete an entitlement and tax reform deal. The process, as some envisioned, would move through regular order, with legislative targets and an outline for a major rewrite of the U.S. tax code.

With the pressure mounting, Ryan made his move during an Oct. 10 meeting between Obama and more than a dozen House Republicans. Boehner, Cantor and other House GOP leaders had pulled together a plan to do a short-term extension of the debt limit and government funding while opening negotiations on a longer-term budget deal.

Just two days earlier, Ryan had published an op-ed in the Wall Street Journal — his favorite policy microphone — entitled: “Here’s How We Can End This Stalemate.” (He had knocked his fellow Young Gun off the page, coveted conservative real estate. Cantor was also in line: he thought The Journal would run his piece that day. Cantor’s piece ended up in The Washington Post.)

Sitting around a conference table in the Roosevelt Room, Obama hammered the Republicans about reopening the government, demanding repeatedly to know “what is it going to take” to get it done. A frustrated Ryan finally stood up and urged them to come together and craft something lasting.

But what senior administration officials aides heard was a Freudian slip. “We’re going to have six weeks to negotiate the debt limit,” Ryan said.

Nobody challenged him, but White House aides mentally filed it away.

By this point, McConnell knew things were going awry with the GOP strategy in the House. So he began fielding suggestions from GOP senators like Rob Portman and Susan Collins, Ayotte and Lisa Murkowski who were working on various proposals that could potentially win Democratic support.

“I certainly was encouraging to all the entrepreneurial activity that was going on with our members and to talk to the Democratic side with the hopes that we can come with a better outcome,” McConnell said.

Even though Collins was picking up support, she never had the full buy-in of party leaders from either side.

It was a veteran Republican senator, Lamar Alexander of Tennessee, who McConnell instead leaned on closely for some critical advice. Several sources said that Collins was upset when she learned Alexander was given this role, given that she had been working aggressively to cut a deal. McConnell aides later said Collins was critical to the end-result and nothing was meant as a slight against her.

But Alexander was important because his politics are more conservative than Collins’ and he has a tight relationship with Sen. Chuck Schumer (D-N.Y.), Reid’s closest ally.

Last Wednesday when Democrats were still insisting they wouldn’t negotiate, Alexander and Schumer began discussing how to construct a deal. They met Wednesday in Schumer’s office, followed by a Thursday meeting in Alexander’s office, and a Friday meeting in Schumer’s hideaway in the Capitol.

Things were going so well that it appeared to several that Schumer was prepared to cut a deal with Alexander, but Schumer knew any deal had to come from Reid and would still have to be vetted by the caucus.

They set up a Saturday morning meeting between Reid and McConnell, two men who have a long personal history that has recently been roiled by a bevy of political conflicts. It was the first time the Senate leaders began to negotiate.

A day earlier, the White House and Democratic leaders put the final kibosh on the Collins plan, telling the rank-and-file to back off the talks. They could not accept the terms of Collins’ offer to extend government financing at lower levels through 2014. Patty Murray of Washington and Barbara Mikulski of Maryland, two powerful Democratic chairmen, refused to consider it.

By Monday evening, it appeared that Reid and McConnell had a deal.

But Boehner wanted one last shot. He told McConnell Monday to hold off any agreement with Reid. McConnell, who faces his own reelection battle in 2014, complied.

Boehner then tried twice Tuesday to rally his conference around proposals that would eke out some sliver of a win after a 15-day government shutdown. His last-ditch play was to reopen the government until Dec. 15 and raise the debt ceiling until Feb. 7. He tried to attach a number of conservative policies, but no combination would’ve passed.

Less than 12 hours later, Boehner declared the proposal dead, paving the way for the final Reid-McConnell solution.

“I like him, he’s a nice person,” Pelosi told POLITICO on Thursday, the day after the shutdown ended.

But Pelosi still seemed stunned that Boehner allowed the shutdown to occur as long as it did, when she repeatedly offered him Democratic support to help pass a bill to reopen the government.

“It isn’t as if he didn’t have a solution,” Pelosi said.

Follow @politico