Republican Sen. Jeff Sessions was now President Donald Trump's attorney general, opening up a Senate seat McConnell would need to focus on in November 2018.

Early this year, he started seeing reports in local Alabama press that gave him pause, someone close to the senator told CNN. The Alabama governor was considering holding a special election this year, rather than next. Should he be concerned about a possible date change that could add new pressure on the party? Sen. Luther Strange, appointed to replace Sessions, said not to be.

Had that conversation gone differently, McConnell might have sought to persuade Gov. Kay Ivey to keep the 2018 election date. He might have called upon the White House to intervene. Instead, Washington Republicans were caught flat-footed when Ivey announced in April that she would schedule the special election early, for this year.

The decision was the first in a series of unimaginable missteps and miscalculations that led to one of the biggest Republican political disasters in recent years, culminating in Republican Roy Moore's defeat Tuesday to Democrat Doug Jones. The result marked the first time in more than two decades that a Democrat had won a Senate seat in deep-red Alabama.

"The remarkable thing is, it's one big, gigantic self-inflicted wound," said Josh Holmes, McConnell's former chief of staff and campaign manager. "The election itself did not need to happen."

From that first fateful decision until Tuesday, the race unfolded for the Republican Party as a political case study in Murphy's Law: whatever could go wrong, did.

And GOP strategists now fear the party could remain stuck in the morass into 2018 and beyond, symbolically linked to Moore even as they try to put his loss behind them.

The race will be remembered as much for Moore as for the test he posed to Washington Republicans, and the divisions he exposed among them, especially between McConnell and the White House.

This is the story of how the Alabama Senate race unfurled and ultimately unraveled, as told to CNN in conversations with nearly a dozen people aligned with the Trump administration, Senate Republicans and the political wing of Steve Bannon , the President's former chief strategist who bucked the party and backed Moore.

A White House divided

Judge Roy Moore was no national Republican's first choice. During the first round of the Republican primary, influential conservatives coalesced behind Rep. Mo Brooks, while McConnell and the National Republican Senatorial Committee favored Strange.

But the President's team was on the fence. Some White House advisers strongly favored endorsing Strange, including Rick Dearborn and the legislative affairs team, Trump's son-in-law Jared Kushner, and the vice president's advisers, according to multiple sources inside and outside of the administration. They argued that Strange had been loyal to the President and would be a key vote on major legislation like tax reform.

Dearborn, a former chief of staff to Sessions, also maintained deep Alabama connections. His wife, a GOP strategist in the state, is staunchly anti-Moore.

The President's political office, however, which at the time included Bannon, cautioned against intervening in the primary, fearing the move would carry unnecessary political risk and, possibly, provoke a backlash among Trump's core supporters.

"To me, getting behind Luther was inconsistent with who we are and how we got here," said one source familiar with the internal discussions.

In the end, one administration official said, there wasn't extensive debate or hand-wringing.

"The President ultimately wanted to do the right thing" and endorse Strange, the official said, "because Luther had been with him on every vote without even asking."

If Strange's loyalty to Trump was a selling point, however, he was weighed down politically by his initial appointment to the Senate by Gov. Robert Bentley, who afterward left office under the cloud of a sex scandal involving a top aide. Plus, Brooks and then Moore sought to frame Strange as a creature of the Republican establishment -- at a moment when that label was toxic in Alabama.

Meanwhile, efforts by national Republicans to help Strange were backfiring. The McConnell-aligned Senate Leadership Fund spent tens of millions of dollars to boost him -- furthering attacks by Strange's rivals that he was bought and paid for by Washington Republicans.

Bannon sees an opportunity

When Bannon departed the White House in August, he and his allies saw McConnell's investment in the race as an opportunity to score points for his own populist-nationalist movement by waging a proxy fight against the Senate leader.

"I was with Steve at his dining room table, and he looked at me and said, 'Surabian, we've got to do this,'" recalled Andy Surabian, Bannon's former deputy in the White House, now a senior adviser to the pro-Trump Great America PAC. "If it wasn't for Mitch McConnell, there's a good chance Steve Bannon would have never gotten involved in this race at all."

With the President still backing Strange, Bannon threw his support to Moore -- ensuring that some of his allies would follow. By the end of September, just before Election Day, they had organized dual rallies in support of Moore: Sebastian Gorka and Sarah Palin appeared at one in Montgomery, and Nigel Farage, Duck Dynasty's Phil Robertson and Bannon headlined another in Fairhope.

"That was a shot across the bow to not only the President, but also Bannon's detractors, including Matt Drudge, who claimed if Steve was fired he would not have any influence," said Sam Nunberg, a former Trump campaign aide who is in Bannon's circle. "There's more power on the outside."

A few days earlier, the President had traveled to Alabama for a rally of his own -- a decision he reached as a result of a meeting with Sen. Bob Corker, in which the President indicated to Corker that he believed Strange would win. Corker warned Trump that the race was not going as smoothly as he thought.

To settle the debate, "they got some consultants on the phone," including former National Republican Senatorial Committee Executive Director Ward Baker, "and confirmed what Corker was saying," said a source briefed on the conversation. "At the end of the conversation, (Trump) committed to go to Alabama."

But by the time the President stood on stage in Huntsville on September 22, even as he heaped praise on Strange, Trump also seemed uncertain about his decision.

"I'll be honest, I might have made a mistake," Trump said.

JUST WATCHED Charles Barkley has stern message for Dems Replay More Videos ... MUST WATCH Charles Barkley has stern message for Dems 00:32

Washington meets Roy Moore

The morning after the runoff election when Moore defeated Strange, McConnell called Moore to congratulate the new Republican nominee. The conversation lasted just a minute, said one source familiar with the call, and Moore said little.

But his victory spoke volumes -- and Republicans in Washington were getting the message.

Bannon hailed the victory as the start of a "revolution." The President expressed his support for Moore, and deleted some of his earlier tweets supporting Strange. In early October, Moore made the rounds in Washington, meeting with lawmakers including Sen. Cory Gardner of Colorado, the NRSC chairman.

As Trump and Republican groups lined up behind Moore for the general election, however, few believed they would need to actively support him. There was little doubt he would be the next senator from Alabama. And one month later, the race seemed to be progressing as expected.

The Story

After the GOP runoff, Brian O. Walsh, president of the pro-Trump super PAC America First Action, said he had put a note on his calendar to poll the race November 9. That morning, he called the group's pollsters -- and, a few hours later, he urgently called them back. They would need to rethink their questions.

Washington Post story had just published , featuring four women who alleged Moore had pursued sexual relations with them when they were teenagers, including one who said she was just 14 years old at the time.

Among Republicans in Washington, "there was a lot of shock, a lot of awe, a lot of confusion as to how nobody discovered it before that day," said one party strategist familiar with the Senate race. "Everyone just sighed and said, 'Well, here we are.'"

As the Republican National Committee and the NRSC cut ties with Moore's campaign, McConnell and other Republicans called for Moore to step aside. Behind the scenes, party operatives assessed possible scenarios: they could attempt to circumvent Moore with a write-in candidate, persuade Ivey to delay the election, or run Moore out of the race altogether.

Although McConnell would in the following days float Sessions as a potential write-in ringer, that idea quickly fizzled.

"Short of (University of Alabama football coach) Nick Saban or Jesus Christ, you were going to have a really tough time," said the Senate Republican campaign official. "So it kind of took the write-in off the table."

Strategists in McConnell's orbit soon landed on an obscure legal precedent, which suggested that Ivey could call a new special election if Strange stepped down and another replacement was appointed, the official said. Sen. Richard Shelby and Vice President Mike Pence, in addition to the vice president's staff, were in communication with Ivey — but the governor wouldn't budge.

Meanwhile, McConnell's allies pitched the White House on the plan, "and initially they were interested," said a Senate campaign official.

But, internally, the President's political shop worried that such a Hail Mary would be "the kind of scheme that voters in Alabama would see right through," according to two sources familiar with their discussions.

"None of it was realistic," said an administration official.

Moore rebounds

Crucially, as Republicans processed and sought to work through the crisis, the President was out of the country completing an extended swing through Asia -- leaving a vacuum at home, with no clear guidance to his allies.

Meanwhile, the talk among Republicans of ousting Moore was energizing Bannon and his network anew. In one internal discussion, "we all agreed that McConnell was trying to kill two birds with one stone and take down Steve with Moore, and we weren't going to let that happen," said Nunberg.

But Bannon first needed to bring some of his influential allies onto the same page.

On November 14, Fox News anchor Sean Hannity stunned some conservatives when he delivered an ultimatum to Moore: "remove any doubt" about the allegations against him, or "get out of this race." Hannity's bold and unexpected stand drew a phone call from Bannon, who urged Hannity to tone down his rhetoric and let Alabama voters decide, a source told CNN at the time. The following evening, Hannity softened his tone, saying the issue "shouldn't be decided by me."

There were still other fires to extinguish. That same week, in an interview with the Associated Press, Ivanka Trump said of Moore : "There's a special place in hell for people who prey on children. I've yet to see a valid explanation and I have no reason to doubt the victims' accounts." The statement would be featured prominently on mailers and in television ads against Moore.

Through intermediaries and directly, Bannon and his network warned the White House that the President could anger his political base were he to call for Moore to step aside, multiple sources familiar with those discussions said. Bannon remained in semi-regular contact with Trump by phone.

Franken changes the landscape

An unrelated event soon convinced some Republicans that the landscape was shifting. On the morning of Nov. 16, as the White House political team met, news was breaking of a woman accusing Sen. Al Franken of sexual misconduct.

Watching the story unfold, White House political director Bill Stepien predicted a pivot point, telling his colleagues, "This changes the conversation, and this will dramatically change public opinion and open the door for Moore," according to sources who were present.

"The light bulb went on for everyone," recalled one official who was in the meeting. Suddenly, the public discussion of sexual misconduct was bipartisan.

JUST WATCHED Roy Moore: It isn't over Replay More Videos ... MUST WATCH Roy Moore: It isn't over 00:49

Trump's endorsement and rally

Following the Thanksgiving holiday, Trump marked a new phase of the campaign as he began to hint at an endorsement of Moore, attacking Jones in a public statement on Twitter.

Trump "(knew) that this is not a sure thing," said a source familiar with the President's endorsement. "He was willing to put his own political capital on the line."

A few days later, Bannon announced to CNN that he would return to Alabama for a rally December 5 to kick off the final week of the campaign, saying he "(looked) forward to standing with Judge Moore and all of the Alabama deplorables in the fight to elect him to the United States Senate and send shockwaves to the political and media elites."

It had become clear that Moore would not be challenged by a last-minute write-in candidate or persuaded to leave the race, and some Senate Republicans grew quieter. On December 3, McConnell said on ABC's "This Week" that he would "let the people of Alabama make the call" on Moore.

McConnell's circle insisted he was not softening his previous stance on Moore, so much as "(acknowledging) that despite our best efforts, Moore will be on the ballot," said one source familiar with McConnell's thinking.

The next day, Trump explicitly endorsed Moore and later called him from Air Force One en route to Utah, saying, "Go get 'em, Roy!"

Groups aligned with the President, including the Republican National Committee and America First Action, followed his lead, announcing they would spend money on the race. Walsh said the decision by America First was a "clinical" one, informed by data on the race, the President's posture, and the legislative implications.

"You can't simply write off a US Senate seat," Walsh said.

But the President's endorsement violently ruptured the GOP, with McConnell's wing of the party standing on the other side of the chasm. The NRSC and SLF announced they would not re-engage in the race.

Following Trump's decision to endorse Moore, the President on one occasion attempted to speak about the race with McConnell, said a Senate campaign official familiar with the conversation. "And McConnell indicated they're going to have to agree to disagree on that issue, and they should talk about other issues instead," the official said.

'You can lose basically everywhere'

The reckoning is likely just beginning.

With Moore's defeat, the President suffers one more political bruising that could cause Republicans to question his broader political strategy moving into 2018.

McConnell could be pressed by donors and party loyalists to defend his decisionmaking that resulted in the party losing a crucial Senate seat.

And Bannon's allies have promised to continue taking on McConnell into the midterm elections. "The war inside the Republican Party is only going to get more vicious and more bloody," said a source familiar with Bannon's plans.

Ultimately, however, all three camps will be forced to grapple with a historic failure in the race for an impossibly safe Senate seat.

"If you can figure out how to screw up a state as red as Alabama," Holmes said, "you can lose basically anywhere."