The stunning defeat of President Trump’s chosen Senate candidate in Alabama on Tuesday amounted to a political lightning strike — setting the stage for a worsening Republican civil war that could have profound effects on next year’s midterm elections and undermine Trump’s clout with his core voters.

The GOP primary victory by conservative firebrand Roy Moore over Sen. Luther Strange could also produce a stampede of Republican retirements in the coming months and an energized swarm of challengers.

It marked yet another humiliation for the Washington-based Republican establishment, particularly Senate Majority Leader Mitch McConnell (R-Ky.), whose allies pumped millions of dollars into the race to prop up Strange and reassure his colleagues that they could survive the Trump era.

Moore’s win, however, also demonstrates the real political limitations of Trump, who endorsed “Big Luther” at McConnell’s urging and staged a rally for Strange in Huntsville, Ala., just days before the primary. The outcome is likely to further fray Trump’s ties to Republicans in Congress, many of whom now fear that even his endorsement cannot protect them from voter fury.

“People think about those things all the time up here,” said Sen. Richard C. Shelby (R-Ala.), referring to unease in elected Republican ranks. “A lot of them won’t be run out of town — they want to stay and fight for their beliefs. But they know Moore’s supporters will come after them anyway.”

President Trump speaks at a campaign rally for Sen. Luther Strange in Huntsville, Ala., Friday. Strange was defeated in the GOP primary Tuesday. (Aaron P. Bernstein/Reuters)

The tremors began before the polls closed in Alabama. Sen. Bob Corker (R-Tenn.), the chairman of the powerful Senate Foreign Relations Committee, announced on Tuesday afternoon that he would not seek reelection in 2018, dogged by complaints from conservatives in his state over his criticism of Trump. A number of Corker's potential primary rivals had already begun talks with wealthy donors.

“If you’re an incumbent, you have to assume the wind is against you,” said consultant Tom Ingram, a longtime Corker adviser. “If you do run, you take nothing for granted and leave nothing on the table. You start out with one big strike against you: You’re an incumbent Republican senator.”

For Democrats, the prospect of further retirements and revived GOP infighting has sparked talk of competing for Senate seats previously thought out of play. That is particularly true with candidates like Moore, long considered a fringe political figure who has, among other things, expressed doubts about whether former president Barack Obama was born in the United States and referred this month to “reds and yellows” in remarks on race. On the eve of the election, Moore, wearing a white cowboy hat and a black leather vest, pulled a handgun out of his pocket and flashed it at a rally.

“It’s an acid flashback to 2010,” said Charlie Sykes, a former conservative talk-radio host, referring to the year when seasoned GOP figures lost Senate primaries across the country as incendiary conservatives charged forward.

“It’s almost as if there is a compulsion in the party to nominate the most ‘out there’ candidate just to show you can, with no concern about what that means for the rest of the party,” Sykes said. “Republicans — and that means Trump, too — have unleashed something they can’t control.”

Hard-line challengers to Senate Republicans seized on the fall of Strange, who had been boosted by Trump and millions in outside Republican spending, as a sign of how the clamor of anti-establishment forces like Breitbart News — chaired by former White House chief strategist Stephen K. Bannon — could empower them, regardless of whether Trump rallies behind sitting senators.

“People everywhere are outraged with the swamp, but there has been hesitation in some states among people who are thinking about it. They wondered whether these senators can be beat. This changes all of that,” said Danny Tarkanian, a GOP businessman running against Sen. Dean Heller (R-Nev.).

Possible foils to other Republican senators facing reelection next year described Moore’s insurgent grass-roots campaign as a model for how they could frame their own bids: He embraced Trump but encouraged the president’s supporters to lash out at McConnell and the party’s leadership.

“I was with Bannon last night, talking it through, and what’s happened in Alabama increases the likelihood that I jump in,” said Mississippi state Sen. Chris McDaniel (R), who is considering challenging Sen. Roger Wicker (R-Miss.), speaking Tuesday before polls closed. “It’s a race that has repercussions across the country.”

McDaniel, who nearly toppled Sen. Thad Cochran (R-Miss.) in a messy 2014 primary election, added, “It’s an in­cred­ibly exciting time. I admire President Trump but people will reach their own conclusions. They’re going to vote against those who play the D.C. games. That means they’ll go against McConnell and against Roger Wicker, who is part of the established order.”

With Corker retiring, seven Senate Republicans are expected to run for reelection next year: Wicker, Heller, Jeff Flake (Ariz.), Ted Cruz (Texas), Deb Fischer (Neb.), Orrin G. Hatch (Utah) and John Barrasso (Wyo.).

For months, only three of them — Flake, Heller and Wicker — were widely seen as vulnerable to primary upsets. But in the wake of Alabama, GOP operatives are no longer ruling out an expanded map of targets for Bannon and his associates, such as former Alaska governor Sarah Palin, who stormed behind Moore’s candidacy to reassert her influence within the party.

“They try to say you’re off the reservation any time there’s a tough vote,” Shelby said.

Veteran Republican pollster David Winston, who works closely with party leaders, said that “given what Bannon has been doing, you could see how other primaries could be of value to him and his network. Alabama was their test case and Moore winning probably opens the door a bit in other places.”

Bannon seems ready to yank open that door, huddling in recent days with Republicans mulling primary campaigns. Tennessee state Sen. Mark Green, who had been considering a Corker challenge, was with Bannon in Alabama. The Mercer family — Bannon’s billionaire backers — have been in touch with these contenders as well and McDaniel said they have encouraged him to run.

When asked about rumors that the Mercers and other donors have pledged more than $1 million to McDaniel, he replied, “It may be more.”

“For Mitch McConnell and Ward Baker and Karl Rove and Steven Law, all the instruments that tried to destroy Judge Moore and his family, your day of reckoning is coming,” Bannon said Monday night at Moore’s election eve rally, listing the names of Republican operatives who are allied with McConnell and spent more than $10 million to boost Strange’s candidacy.

“They think you’re a pack of morons, they think you’re nothing but rubes, they have no interest at all in what you have to say, in what you have to think or what you want to do,” Bannon told the crowd.

Voting with Trump and donning a red cap emblazoned with “Make America Great Again,” as Strange did with Trump last week, may not stave off primary challengers who style themselves as GOP rebels.

“What we’ve noticed is that Trump voters aren’t necessarily looking for Trump, they’re looking for candidates who are outsiders like Trump and will lean toward people with that sort of background,” said Robert Cahaly, a Republican pollster whose firm surveyed the Alabama race. “Strange seems establishment, he’s not seen as disruptive at all, so he was at a disadvantage.”

Retirements among House Republicans could rise as well.

“More and more Republicans may say I don’t want the hassle from the activists on the left and the Trump Republicans on the right,” said GOP consultant and Trump critic Rick Wilson. “There’ll be more who say, ‘I’ll hang up my spurs.’ ”

Trump’s role in those 2018 primaries is yet to be determined, according to his confidants and White House officials.

“The president went into Alabama because of loyalty and political necessity,” said Christopher Ruddy, the chief executive of Newsmax Media and Trump’s friend. “When he’s faced with this kind of situation in the future, he’ll support his friends but the question is how far he goes. He may be a little careful.”

One of Trump’s first choices will be how much to get behind Moore, who GOP leaders fear could be a burden to Republican candidates nationally. At Trump’s Huntsville rally Friday — when he conceded he “might have made a mistake” in backing the incumbent — Trump vowed to “be here campaigning like hell” for Moore if he won, while acknowledging his limitations.

“Roy has a very good chance of not winning in the general election,” Trump said during the rally. “Roy is going to have a hard time, but I will be backing him if he wins.”

Next month, former vice president Joseph R. Biden will campaign in Alabama for Doug Jones, a former prosecutor whom Democrats believe could be competitive against Moore.

McConnell’s orbit dismissed suggestions late Tuesday that the Alabama result crippled his standing and instead chalked up Strange’s defeat to the party’s stalled efforts to pass legislation and local dynamics. Strange, a former state attorney general, was appointed earlier this year by a Republican governor who later resigned amid a sex scandal. Strange’s defeat came on the same day McConnell shelved the latest GOP health-care proposal.

“There is going to be a rush to overanalyze Alabama,” said Josh Holmes, McConnell’s former chief of staff. “McConnell showed he will go to war for Republican senators, come hell or high water. A lot of folks out there would have cut bait when an election turns but that’s not who McConnell is.”

And for both sides, it’s war.

“I fully anticipate a whole lot of people who had nothing to do with the result taking credit for Alabama,” Holmes said, mentioning Bannon and Breitbart News. “It’ll lead to more friendly fire in our party, which will make it tougher, not easier, to pass health care and taxes. What we need is cohesion.”