Tuesday's special U.S. Senate election in Alabama was never destined to bring good news for the Republican Party, no matter the outcome. But the stunning victory by Democrat Doug Jones was a devastating blow to a party wracked by divisions and intraparty rivalries and a humiliating defeat for President Trump.

For some Republicans, the fact that the controversial and flawed Roy Moore will not be their new senator from Alabama came with some measure of relief. But the consequences of that outcome will reverberate over the coming months in one legislative battle after another. An already razor-thin margin in the Senate becomes even more tenuous for the party in power.

Beyond that, the tumultuous election served to expose further the fissures, fault lines and rivalries that have only widened in the 13 months since Trump captured the White House. The election provided the capstone to a year of tumult inside the GOP, and at a time when the party controls the levers of power in Washington and states across the country, the Alabama campaign was one more reminder that this is a party facing a major identity crisis and no easy answers for how to resolve it.

In the face of results that showed Jones leading by 20,000 votes and by more than a percentage point, Moore signaled late Tuesday that he had not given up the fight. He refused to concede the race and said he would seek a possible recount. That decision will produce more heartburn among establishment Republicans, who would prefer to see him fade quickly and quietly into obscurity.

Trump suffered mightily after fully embracing Moore in the final weeks of the campaign, despite credible allegations that Moore had engaged in sexually improper behavior with teenage girls when he was in his 30s.

It was the second such setback for the president in a state he won by 28 points just a year ago. In the GOP primary earlier this year, he had endorsed, with limited enthusiasm, Sen. Luther Strange, who had taken the seat of Jeff Sessions when Trump made Sessions his attorney general. For Trump, nothing good has come from that appointment — from a special counsel investigation into Russia's role in the 2016 election to a pair of losses in the Alabama races.

The outcome was a bad moment as well for Stephen K. Bannon, once the president's White House strategist and a man with the expressed commitment of bringing down the GOP establishment. More than Trump, Bannon was all in for Moore, campaigning on his behalf while railing against those in the establishment who had been overtly critical of the GOP nominee.

Bannon has threatened a year of turmoil for the GOP, but in this high-profile test, both he and the president proved to have limited ability to transfer Trump's popularity to another candidate. This won't be the last the party hears from Bannon, but he will be viewed differently as a result of what happened on Tuesday.

For those reasons, many Republicans will privately be pleased to see Bannon and even Trump get their comeuppance. But that doesn't resolve the split within the party over the direction it should take. As long as Trump is president, this is the division and the reality that Republicans will live with — an uneasy coalition at best.

Moore brought to the race a history of defiance to the rule of law, twice having been removed from the state Supreme Court for defying orders. He was hardly popular despite defeating Strange in the primary, but in channeling Trump's outsider, drain-the-swamp rhetoric, he appealed to many in the Trump and GOP coalition who wanted to stick the party's congressional leadership in the eye.

His candidacy took a damaging hit after the primary, when The Washington Post reported the accusation that he had initiated a sexual encounter with a 14-year-old girl when he was in his 30s as well as accounts of other women who said he preyed on them as teenagers. The race turned from an almost-certain victory for the Republicans to a competitive contest that would leave the party with no good outcomes, win or lose.

1 of 76 Full Screen Autoplay Close Skip Ad × Doug Jones defeats Roy Moore for the U.S. Senate seat from Alabama View Photos Republican Roy Moore, who has been accused of sexual misconduct, faced off against Democrat Doug Jones in a special election. Caption Republican Roy Moore, who has been accused of sexual misconduct, faced off against Democrat Doug Jones in a special election. Jabin Botsford Buy Photo Wait 1 second to continue.

The fact that he will not be in the Senate spares Republicans from what could have been a spectacle of controversy—a likely ethics investigation that could have led to Moore's expulsion but that even if it did not, would keep him and the allegations against him in the forefront of the political conversation — to the detriment of the GOP.

A number of Republicans said Tuesday they had feared the worst from a Moore victory, that with him as a sitting senator, supported by the president and the Republican National Committee in his campaign, the party would have put itself on the side of a candidate with racial and other views anathema to most Americans and on the wrong side of the issue of sexual harassment at a moment when the ground is shifting dramatically toward zero tolerance for such behavior.

These Republicans expressed concerns that the GOP could lose the support of young voters for a generation as well as declining support from suburban women who have been part of their coalition in their rise to power. The preliminary exit polls showed the validity of some of those fears, as voters under age 45 went overwhelmingly for Jones against Moore. Women also backed the Democrat's candidacy, although white women supported Moore.

However contentious the campaign proved to be during the final weeks, the aftermath could be similarly destabilizing for the Republicans. Party leaders will attempt to put the election behind them and return to their efforts to pass a tax bill and deal with other pending legislative issues.

But recriminations are likely, especially with a president who hates to lose and has a record of lashing out when things have not gone his way. The president was opposed in this contest by Senate Majority Leader Mitch McConnell (R-Ky.), who had called for Moore to withdraw after the allegations of sexual misconduct. Though the two will try to come together over the tax cut bill, the ill will that has long existed will remain.

Trump faces his own accusations of sexual misconduct, and as the national debate about those issues rises, Democrats are becoming more aggressive in pushing to have Trump held accountable. Moore's defeat will be seen as a sign that the public is becoming far less tolerant of such behavior.

The president's allies have said voters took the charges against him into account and elected him anyway. But Moore's defeat could be read as a shift in the public mood and Democrats likely will push the issue at every opportunity. Trump's Twitter blast Tuesday morning at Sen. Kirsten Gillibrand (D-N.Y.) as someone willing to "do anything" for campaign contributions further inflamed the issues of sexual misbehavior.

Beyond that are questions about how much the addition of one seat to the Democrats' column changes the calculus for control of the Senate in 2018. The map remains difficult for the Democrats, and they are still in need of a genuine renewal. But with control of the House already in play, the Alabama race, coupled with the results in Virginia last month, suggest there is energy among rank-and-file Democrats that could put the Republicans at a big disadvantage next year.

It's always easy to overstate the importance of a single election and no doubt that's the case even for Alabama. But this is one contest that seemed to bring together much of what is in the forefront of the political debates, from the popularity and influence of the president to the fractured Republican Party to the issue of sexual harassment. For Republicans, it was a bad night, no matter how it was measured. The question is where they go now.

Read more:

As Democrats add Senate seat, GOP left to bicker over what happened in Alabama

Heeding Bannon in Alabama election, Trump gambles and loses

Democrats are jubilant — and newly confident about 2018 — as Alabama delivers win on Trump's turf

How different groups voted in Alabama