Washington (CNN) It was the moment when hesitation became resolve.

"Let's get this f***ing thing done!" former combat fighter pilot, Air Force Colonel and Arizona Rep. Martha McSally exhorted her colleagues in a private pre-vote pep rally on Capitol Hill, as House Republicans entrusted their futures to fate and agreed to vote to repeal Obamacare.

Nearby, House Speaker Paul Ryan was "giddy," said one colleague, sensing the narrowest of reputation-saving wins after a trial by political fire. Down Pennsylvania Avenue, as Thursday's vote neared, President Donald Trump settled in front of a TV, his Twitter account poised, but slipping into the unusual state of calm that aides say envelops the hyperactive commander-in-chief when moments of history beckon.

For Democrats, by contrast, there was only deflation and despair -- as Obamacare, the law with nine lives, absorbed a dramatic blow. But thoughts of revenge also stirred. GOP lawmakers filed out of the House to a serenade: " Na, Na, Na, Na, Hey, Hey, Goodbye ," from Democrats convinced the Republicans had sealed their fate in the 2018 mid-terms.

Despite the Trump and GOP victory rally at the White House, the past few months are just an appetizer as the bill goes to the Senate and members head home to their constituents. There will be more rounds of Republican strife and debates over arcane parliamentary procedure with a new cast of lawmakers. Vice President Mike Pence -- who keeps Capitol Police officers busy with his frequent visits -- will spend more time in his Hill office. We'll see a new report of how the bill will impact Americans. The tweets will undoubtedly continue.

This article relates behind-the-scenes negotiations and the emotional and political storm that raged on Capitol Hill as the House GOP belatedly, but triumphantly, honored a promise to its voters that it first made seven years ago and has renewed many times since.

Based on dozens of conversations with Republican and Democratic leaders, lawmakers and political aides by CNN's teams on Capitol Hill and in the White House, it reveals how House GOP members finally steeled themselves to overcome the infighting and inaction that tarnished Trump's First 100 Days.

It is also the story of how the GOP decided that the price of inaction now was greater than the risk of passing a bill that even many Senate Republicans believe is deeply flawed.

"I think people in the House just simply wanted to get a bill out of the House and hoped that the Senate did something with it," said Rep. Charlie Dent, one of 20 Republicans who voted no.

But for those on the other side, victory tastes sweet.

"This is a great plan," Trump said at the White House, seemingly looking forward to the next round. "I actually think it will get even better. This is a repeal and replace of Obamacare. Make no mistake about it."

Back from the brink

Flash back six weeks and it was all so different. After pulling an earlier version of the bill, a defeated Ryan admitted that Obamacare was "the law of the land," and that the GOP, for now, had missed its moment.

But health care reform still had a faint pulse.

A former opponent of the House bill, Sen. Rand Paul, wearing a Duke baseball cap from his alma mater, surprised the White House press pool after returning from golf with Trump on April 2, saying a deal was getting closer.

The President tweeted that "talks on Repealing and Replacing ObamaCare are, and have been, going on, and will continue until such time as a deal is hopefully struck."

Talks on Repealing and Replacing ObamaCare are, and have been, going on, and will continue until such time as a deal is hopefully struck. — Donald J. Trump (@realDonaldTrump) April 2, 2017

It seemed like Trumpian bluster.

Ryan was also quietly regrouping. He let the dust settle amid humiliating questions about his leadership. Critics highlighted his apparently misfiring relationship with Trump.

In reality, that impression was premature. The two men -- opposites in temperament and style -- grew increasingly close in the foxhole in the weeks to come.

Even so, there was no immediate sense among GOP leaders that health care's time had come again. Committee chairs were gung ho to take on tax reform.

But Ryan did encourage members to keep talking about health care. Though optimism had been shattered, a more bottom-up approach was worth a shot. The Wisconsin Republican reasoned that time and rising political pressure on his members were needed to knit party splits before he could try again.

Ryan's top health care staffer, Matt Hoffmann, served as the go-between as Rep. Mark Meadows, chairman of the Freedom Caucus and Rep. Tom McArthur , a second-term New Jersey lawmaker and chair of the Tuesday Group moderates, worked to fuse divisions that sent the American Health Care Act crashing.

Throughout April they swapped legislative language, finally agreeing on a deal to allow states to seek waivers to weaken several key Obamacare reforms that protect those with pre-existing conditions. But in a concession to moderates, the provision would not apply to those who maintained continuous coverage.

Once what became known as the MacArthur amendment was codified, whip teams set about testing its support in the Republican conference and solidifying the votes of Freedom Caucus members, the senior GOP source said.

The White House was agitating for a vote as a capstone to a barren First 100 Days. A week ago, House leaders decided not to try to ram the bill through just to meet the arbitrary deadline. But despite another perceived failure, the process was "100 percent still alive," one senior GOP aide said.

Questions still lingered about pre-existing conditions -- resulting in Rep. Fred Upton's bombshell announcement that he would vote no, a brick wall that could have again blocked the GOP's efforts.

But after a meeting with the President alongside his colleague Billy Long of Missouri and a guarantee that funding for high risk pools would rise from $5 billion to $8 billion, Upton came on board. Though Democrats and many policy experts say $8 billion is a drop in the bucket of the cash needed to fund high risk pools, Upton's decision was crucial.

"It gave our guys a clear-cut reason to get to yes," one senior GOP aide said.

By Wednesday night, less than 12 hours after the full details emerged of the latest change to a seemingly ever evolving, always-rejected piece of legislation, Republican leaders met in Ryan's office. They didn't have a solid 216 yes votes, aides say. But they were close. Close enough to force the issue.

"It was time -- we felt it was moving in the right direction, but we also knew we'd hit a point of no return," one person directly involved in the process said.

Thursday, it was clear the play had paid off. They were locking in votes. Pledges from the Department of Health and Human Services helped flip two members. Leadership guarantees of future legislation brought along another. Ryan, who generally eschews the hard, one-on-one sell with wavering members, did just that, several times, one source said.

Implicit in all of it was protection --- in the form of supportive GOP groups come campaign time --- that would be there in spades for endangered members who went along, several sources said.

One member in the conference meeting, where colleagues were greeted by the theme tune from "Rocky" and snapshots of General George S. Patton, as well as McSally's rallying call, said the tone of Ryan's message to his troops was simple: "It's time to roll."

Trump's role

Trump waited for the vote in typical style: by tweeting.

"If victorious, Republicans will be having a big press conference at the beautiful Rose Garden of the White House immediately after vote!" he wrote Thursday afternoon.

JUST WATCHED Sanders: Thousands will die if bill passes Replay More Videos ... MUST WATCH Sanders: Thousands will die if bill passes 01:12

And after weeks of misfires that exposed his inexperience in wooing Congress, he got his win.

"Coming from a different world, and only being a politician for a short period of time, how am I doing? Am I doing OK? I'm President. Hey, I'm President, do you believe it, right?" he crowed in the Rose Garden.

Months ago many of those beaming Republican leaders behind Trump had not believed it or in him. There had been whispers that Trump's loose tongue revealed his ignorance about what was in the bill and made compromise harder.

But by Thursday afternoon, Trump was pouring praise on Ryan and his crew, and it did seem that, in the President's words, the party had "developed a bond."

A White House official told CNN that Trump had kept up an intense push behind the scenes, ensuring that aides supported MacArthur and Meadows as they sought common ground and tasking HHS Secretary Tom Price with briefing wavering members on Medicaid funding.

He and Ryan swapped notes in multiple late night phone calls.

"The President's been incredibly engaged in this process, particularly over the last several days," deputy press secretary Sarah Sanders said.

For all his ham-fisted interventions, Trump has evolved through the health care process, aides believe. He now knows artificial deadlines cut no ice in Congress.

He's also learned the legislative process is more complex than the business world — after running for office proclaiming his deal-making skills would take Washington by storm.

"It's not so cut and dry here," one aide said, explaining Trump's thinking. "There's so many more players involved and everybody has something that they want."

Still, you can't take the businessman out of the President -- he still prizes the personal touch, the person said.

Trump's flexibility likely helped too.

"This president probably has more philosophic dexterity than most of the presidents I've dealt with in the past," said South Carolina Rep. Mark Sanford, who voted for the bill. "That makes it a little bit different because typically there is sort of a fixed starting point or a fixed ending point on where an administration might be."

As the votes rolled in, Trump's coterie gathered in the dining room off the Oval Office, among them, Pence, Price, Trump's daughter Ivanka, son-in-law Jared Kushner, top Economic Adviser Gary Cohn, adviser Steve Bannon, counselor Kellyanne Conway, press aide Hope Hicks, political aide Dan Scavino and Centers for Medicare and Medicaid Services Administrator Seema Verma.

It felt like election night all over again. "We were all overjoyed and he was very docile, frankly. Very hopeful but not prematurely celebrating. We saw the same thing today," one official said.

Pence steps up

While Trump took the plaudits, many players in the drama spoke approvingly of Pence.

Even Dent, who voted against the bill, praised the Vice President's soft sell technique.

"He wanted to work with me. Very civil, very constructive meeting as you would expect from Mike Pence," Dent recalled. "I always get the sense that Mike Pence is the velvet glove, the soft touch. The good cop."

"He knows how to talk to people," he added.

Pence threw himself into the renewed push to pass health care soon after returning from a marathon trip to Asia. He was all over Capitol Hill over the last few days, forming a partnership with White House Chief of Staff Reince Priebus, who roamed the House floor as the vote went ahead.

Pence's ubiquity did not go unnoticed.

A Capitol Police officer was overheard telling a colleague how he doesn't like the days when Pence is on the Hill because he likes to mingle so many members, the responsibility of protecting him becomes even more intense.

Democratic despair, GOP goes home

In 2010, then-Vice President Joe Biden called Obamacare a "big f***ing deal. His sentiments were similar, for other reasons, on Thursday.

"Day of shame in Congress. Protections for pre-existing conditions, mental health, maternity care, addiction services -- all gone," Biden tweeted.

Day of shame in Congress. Protections for pre-existing conditions, mental health, maternity care, addiction services -- all gone. — Joe Biden (@JoeBiden) May 4, 2017

Cries of "shame, shame, shame," greeted GOP lawmakers as they walked down the ornate steps on the East Front of the Capitol.

House Minority Leader Nancy Pelosi warned the GOP: "You have every provision of this bill tattooed on your forehead. You will glow in the dark on this one."

But all may not be lost yet for the Democrats. The bill must go now to the Senate, and it emerged Thursday that the chamber will only use the House bill as a skeleton before writing its own legislation.

Now, House members are going home, where protesters and raucous town halls certainly await.

There is a feeling of accomplishment, several members acknowledged, that so far is a novelty in the new Republican era. They know what is ahead, and are ready.

"We know the fight that's coming," one senior GOP aide said. "We want that fight."