Taking the stage just before midnight as the Iowa Democratic Party's slow-motion disaster unfolded on caucus night, the former mayor of South Bend, Indiana, claimed victory before any official tallies were in.

"So we don't know all the results, but we know by the time it's all said and done, Iowa you have shocked the nation. Because by all indications, we are going on to New Hampshire victorious," Buttigieg told his supporters, in a move that struck some as audacious.

But Buttigieg, whose campaign had built one of the best organizations in the state, was confident in the data coming from his team.

Inside Buttigieg boiler room Monday night, Buttigieg's team was crunching the internal data they were getting from their precinct leaders in 1,678 precincts across the state, using photos they received of the caucus math to tally up the delegate totals.

As the clock ticked past midnight, 1,259 precinct chairs had sent full data sets to the campaign -- a number that even surprised Buttigieg's aides in the boiler room. They had turned to their own numbers because of the breakdown of the vote reporting process engulfing the Iowa Democratic Party.

His pronouncement of victory was premature -- with 100% of precincts reporting on Thursday night, he held a narrow lead over Vermont Sen. Bernie Sanders in the all-important state delegate equivalents, with no winner declared. But his strong performance in Iowa -- ahead of current US senators and a former vice president -- was a huge feat for the 38-year-old former mayor who just one year ago was teaching people how to pronounce his last name (It's Boot-edge-edge ).

By Sunday evening, Buttigieg held a 0.1% lead over Sanders in the state delegate equivalent count, according to updated vote numbers and a new national delegate estimate from the Iowa Democratic Party.

If there are no requests to recanvass or recount, Buttigieg would be the winner of the Iowa caucuses.

"This validates the idea that we can have a message -- the same message -- connect in urban and rural and suburban communities; that we can reach out to Democrats, and to independents, and even to some future former Republicans ready to bring change to this country," said Buttigieg in Laconia, New Hampshire, last week. "It validates the idea that we can expand a coalition not only unified around who it is we're against, but around what it is that we're for."

"It validates for a kid somewhere in a community wondering if he belongs, or she belongs, or they belong, in their own family," he said, his voice swelling with emotion as he alluded to being the first serious presidential contender who identifies as gay, "that if you believe in yourself and your country, there's a lot backing up that belief."

Buttigieg speaks to supporters on February 4, in Laconia, New Hampshire.

Buttigieg's performance in Iowa solidifies his rise from a small city mayor who won his second term with a mere 8,500 votes to a major force in Democratic politics. In the exit polls, the fresh-faced mayor who was promising a more positive politics showed strength across rural, urban and suburban areas, as well as the 31 "pivot counties" that voted for Obama and then flipped to Trump.

He proved to be a palatable second choice within Iowa's complex caucus system, where voters must choose a second candidate if their first choice doesn't meet the 15% viability threshold.

Buttigieg and his team had always understood that Iowa was his best shot for a sling-shot effect, one that could remedy his lack of name recognition nationwide and ease concerns about whether a young, relatively inexperienced former mayor could get elected. So, they poured their energy -- and later their huge fundraising advantage -- into organizational muscle that would propel him into contention in Iowa's 99 counties and demonstrate that he had broad appeal across the Democratic Party.

From obscurity to top tier

The unquestionable turning point for Buttigieg was his first CNN town hall in March 2019, where the former Rhodes Scholar and Afghanistan veteran introduced himself to the nation as the candidate from the next generation.

He shared his unusual background governing in the red state of Indiana as a gay man, and how that state's backlash to then-Gov. Mike Pence's "Religious Freedom Restoration Act" -- which Buttigieg called "a license to discriminate"-- showed him "there is a belief in just decency that really does stand against that kind of social extremism."

Buttigieg speaks with CNN's Jake Tapper during the CNN Democratic Presidential Town Hall in Austin, Texas, March 2019.

But what was most striking was how he spoke openly about his faith, explaining how his interpretation of scripture differed from that of Pence (whose term as Indiana's governor overlapped with Buttigieg's time as mayor of South Bend).

"His interpretation of scripture is pretty different from mine to begin with," Buttigieg said in that town hall. "My understanding of scripture is that it is about protecting the stranger and the prisoner and the poor person and that idea of welcome. That's what I get in the gospel when I'm in church."

The appearance drew rave reviews from Democratic strategists, with Obama's former adviser David Axelrod, a CNN contributor, predicting on Twitter that Buttigieg's "crisp, thoughtful and relatable" performance would catapult him from the "long shot" category into contention.

That night, Buttigieg's communications strategist Lis Smith coaxed the candidate, who normally favors beer and whiskey, into toasting the milestone with a glass of Prosecco.

"You know what you did, right?" she asked him.

He couldn't wipe the grin off his face: "I think it was good," he replied. "It was good, right?"

The comparisons to Obama were inevitable, a young introspective upstart with little political experience but enough gumption to pursue the White House.

Suddenly the money and the media requests began pouring in. The campaign's fundraising goal had been $1 million for the first quarter. Within 24 hours they had raised $600,000. In three days, they topped the 65,000 donors they needed to qualify for the first debate.

Buttigieg talks to members of the media as he leaves a meet-and-greet at Madhouse Coffee in April 2019 in Las Vegas, Nevada.

It allowed Smith to fully deploy her strategy of saying "Yes" to everything -- media outlets where other candidates wouldn't dare appear. In two notable examples, Buttigieg did an interview with TMZ and appeared on Showtime's talk show "DESUS & MERO," drinking whiskey from a bottle wrapped in a brown paper bag.

A finely tuned organization

Massachusetts Sen. Elizabeth Warren, who became the race leader in Iowa in September 2019, had built what many of the state's political strategists viewed as the best campaign organization in the Hawkeye State. But Buttigieg was ready for the hustle, recruiting his own team of top talent.

Both Warren and Buttigieg were relying on "relational organizing," with volunteers focusing on their community of friends and colleagues, rather than cold-calling people they didn't know. The Buttigieg campaign, according to aides, codified this program by creating a tool for volunteers where each was asked to enter a long list of friends and colleagues and then track their contacts with those people.

"Any volunteer who is doing outreach can log in and map out their friends, family, neighbors, book clubs, fellow students, whatever networks they are part of and really kind of track how they are engaging them," said a Buttigieg spokesman. "As part of the website, they have links to news stories, videos of Buttigieg speaking, local events they can go to" that they can share with people.

"You have your own network in Iowa, and who is more powerful to reach out to these people than someone that they know?" the spokesman said.

Buttigieg campaigned at breakneck speed -- sometimes with four to five events a day. He was disciplined and constantly on message. As a well-known introvert who acknowledged that he draws energy from his time alone, his rare breaks were on the treadmill in the hotel gym, running hard.

Buttigieg during a canvassing launch event on February 3, in West Des Moines, Iowa.

In mid-November, he rose the first position in Iowa polls , eclipsing Warren. By January, he had expanded his operation to nearly 200 aides and more than 20 field offices. (In the sprint to the finish between the New Year and the caucuses, he held more than 50 town halls).

Buttigieg was also raking in campaign donations from high-dollar donors -- the kind of campaign cash that had eluded California Sen. Kamala Harris and New Jersey Sen. Cory Booker. While all of the donors "dated around" as one strategist put it, there was an interest in landing a spot on the team early.

"It reminded me of early Obama and the shooting-fish-in-a-barrel phenomenon, where everyone I called (to ask for money) said yes," said Rep. Don Beyer, Buttigieg's first congressional endorser.

Rufus Gifford, an early Buttigieg donor, said the donor universe hadn't seen "anything quite like that since the rise of Obama." After the CNN town hall in March, the political class and donor class were intrigued.

"From there he went on this surge which definitely was reflected in his fundraising number," said Gifford, who has since endorsed former Vice President Joe Biden and joined his finance team. "Everyone wanted to meet him, everyone wanted to be there. In all of the largest markets around the country, people were scratching and clawing to be the first people to host Pete because they knew the events would sell out."

By mid-November, his campaign aides knew he had a shot. Buttigieg's caucus director toured the state, training well over 1,000 precinct captains -- helping them master the talking points to win over voters who were supporting a lower-tier candidate like Minnesota Sen. Amy Klobuchar. They hammered the notion that each precinct captain could help train other volunteers to "find a bridge" with supporters of less viable candidates and win them over.

The former mayor drew a huge crowd of supporters to his rally before the pivotal Liberty and Justice dinner in November. With their faces painted blue and yellow, his entire cadre of volunteers spanned several city blocks in Des Moines as they marched from Coles Commons to the dinner up the hill at the Wells Fargo Arena. Many were holding signs that said "Pete for Iowa" -- and there was a representative from almost every one of Iowa's 99 counties. Buttigieg led the way in a brown leather jacket in the drizzling rain, holding hands with his husband Chasten.

Pete Buttigieg walks with his husband Chasten Buttigieg before the Iowa Democratic Party Liberty & Justice Celebration on November 1, 2019 in Des Moines, Iowa.

It was a remarkable show of organizing strength on the same day that Texas Rep. Beto O'Rourke, another youthful longshot, dropped out.

The greatest struggle Buttigieg faced as he ran through Iowa didn't come into play in the overwhelmingly white state: His inability to win over voters of color. The former mayor, dogged by questions about his handling of issues within the South Bend police department, has barely registered -- if at all -- in polls of voters of color, an issue that could create an problem in Nevada and South Carolina, two states where a large portion of the electorate is either Latino or African American.

Iowans would sometimes ask Buttigieg about his lack of support from voters of color, using it to question his ability win the Democratic nomination and take on Trump.

The issue has weighed on Buttigieg's staff, too. Days before the Iowa caucuses, CNN and other outlets reported that some staffers of color raised concerns to the campaign that their opinions have been undervalued and that they have faced pressures associated with belonging to a campaign that has struggled to win support from voters of color.

To allay those concerns in the closing days in Iowa he was introduced at some of his events by two of his most prominent black supporters, Maryland Congressman Anthony Brown and Waterloo, Iowa, Mayor Quentin Hart.

Final days of Iowa

As other campaigns watched Buttigieg rise, the attacks began. Warren forced him into a debate over transparency, taking issue with his high-dollar fundraisers and the fact that he had not opened them to reporters despite persistent requests over many months. His detractors tried to make an issue of the fact that he had worked for the consulting firm McKinsey & Company early in his career.

He was pilloried online and at the December debate in Los Angeles for headlining a fundraiser at Hall Wines, a winery owned by Kathryn Hall, who was the US ambassador to Austria from 1998 to 2001, and her husband, Craig.

On Twitter, supporters of Sanders and Warren campaigns stirred up outrage about the fact that dinner was served in the wine cave under a chandelier constructed from 1,500 Swarovski crystals.

But as they tried to brand Buttigieg as the candidate of the elite, he made a compelling argument that the Democratic nominee would need substantial fundraising power to face off against President Donald Trump.

Buttigieg also went on the attack against Warren, who had been riding high throughout the summer. That surge made her the top target of more moderate contenders like him, who sought to portray Warren's plans as unrealistic in an effort to stoke voters' doubts about her candidacy.

During that Ohio debate, Warren's rivals sought to use Sanders' frankness about the fact that taxes would go up for the middle class under his "Medicare for All" plan as a cudgel against Warren, who kept insisting that middle class costs, overall, would not rise.

"This is why people here in the Midwest are so frustrated with Washington in general and Capitol Hill in particular," Buttigieg said, noting Warren's refusal to answer a "yes" or "no" question about on the impact on taxes.

Sen. Elizabeth Warren speaks as Buttigieg looks on during the Democratic Presidential Debate at Otterbein University on October 15, 2019 in Westerville, Ohio.

At the same time, Buttigieg's campaign was trying to deal with their three biggest structural weaknesses. His name recognition was still limited in key states beyond Iowa. He was literally at zero in some polls among African American Democrats, the most critical constituency in many of the coming primary states. And the polls suggested he had a dearth of support among younger voters who had flocked to Sanders and Warren.

While older voters in Iowa were enthralled with the young former mayor, and often compared him in interviews to President John F. Kennedy, some of his younger antagonists portrayed him as a Wall Street sellout because he had chosen a more moderate platform than Sanders and Warren.

A group of young protesters began interrupting Buttigieg at some of his events and their protests became so routine that at one event in December at Grinnell College, Buttigieg invited them to begin their interruption, knowing it was coming. "Do you want to go ahead and do the thing?" he asked them.

They held up signs: "Wall Street Pete," a reference to his days at McKinsey. Another sign said "Youth to Pete: You will Kill Us."

"You will kill us?' That's really mean!" Buttigieg exclaimed. "I'm here to help you!"

As the caucuses drew closer, the competition between Biden and Buttigieg also heated up in January with both candidates vying for more moderate voters.

Biden's closing argument on television portrayed him as the safe, steady choice who could take on Trump. The former vice president repeatedly argued that this presidential race was no time to gamble on a political novice.

Buttigieg pushed back forcefully. "I hear Vice President Biden saying that this is no time to take a risk on someone new," Buttigieg said in Decorah, Iowa. "But history has shown us that the biggest risk we could take with a very important election coming up is to look to the same Washington playbook and recycle the same arguments -- and expect that to work against a president like Donald Trump."

"I don't know what Pete's talking about, he's a good guy, and that must be a sign that things are getting a little tight," Biden responded during an impromptu stop at a Dairy Queen in Pella.

The former vice president laughed when asked what his biggest contrast was with the former mayor: "You know I've (gotten) more than 8,600 votes in my life."

But Buttigieg's message resonated in Iowa, in part because he invoked the legacy of President Barack Obama, another youthful, politically inexperienced candidate, to rebut questions about his age in a top tier dominated by septuagenarian candidates.

"I know why hope went out of style for a while in our political vocabulary in a dark and divided moment," Buttigieg said Sunday at his final rally in Des Moines. He called on his crowd to surprise the nation again like they had in 2008 when he too had knocked on doors for Obama.

"Are you ready to make history one more time tomorrow evening?" he asked the raucous crowd. "Are you ready for that sunrise when we put the Trump era behind us? ...Iowa, starting tomorrow, I believe you are going to make me the next president of the United States."