WASHINGTON (AP) — Weary national Republicans breathed a collective sigh of relief on Wednesday, a day after voters knocked out their own party’s scandal-plagued candidate in deep-red Alabama. Yet all is not well in a party confronted with new rounds of infighting and a suddenly shrinking Senate majority heading into next year’s midterm elections.

A semi-humbled President Donald Trump conceded that Roy Moore’s loss was not his preferred outcome. He said he “would have liked to have had the seat” and an important Senate vote as he and GOP lawmakers scratch for legislative victories.

But he also acknowledged, “A lot of Republicans feel differently. They feel very happy about the way it turned out.”

Indeed, it was easy to find establishment-minded Republicans — in and out of Washington — who cheered Moore’s loss as the impact of the Alabama stunner echoed throughout the political world. The prospect of a high-profile Republican senator dogged by sexual misconduct accusations — and an all-but-certain ethics investigation — unnerved a GOP that’s fearful of an albatross on its candidates in next year’s campaigns.

Republican Alabama Sen. Richard Shelby said that Moore, a fiery conservative, would have brought a “radioactive” element to the Senate GOP.

“I’m relieved and I believe a lot of Republicans are relieved that Roy Moore and some of his people aren’t the face of the Republican Party that I know,” said Shelby, who cast a write-in vote for another Republican and never backed down in his opposition to Moore.

More than 22,000 write-in votes were cast Tuesday, more than the margin of difference between the winner and loser, suggesting many other voters refused to vote for a Democrat but couldn’t accept Moore.

Meanwhile, the former state Supreme Court chief justice said he is waiting for the “final count” in the race. In a video released by his campaign Wednesday, Moore said that it had been a close race and that some military and provisional ballots had yet to be counted.

Moore said he was waiting for certification of the final vote by the Alabama secretary of state, which is expected to occur sometime between Dec. 26 and Jan. 3.

Unofficial returns show that Democrat Doug Jones defeated Moore by about 20,000 votes or 1.5 percent.

Moore released the message several hours after Jones urged him to “do the right thing” and concede. Moore, who is known for his evangelical politics, called the election a battle for the “heart and soul” of the country

Sen.-elect Doug Jones’ stunning Democratic victory marked a major setback for Trump and top political ally Steve Bannon. They had devoted time, resources and political capital to Moore in recent days, even as he faced the allegations of sexual misconduct and espoused views that alienated women, racial minorities, gays and Muslims.

Despite the outcome’s relief for the GOP’s pragmatic wing, the fight for the party’s soul was hardly decided with one Alabama special election.

Allies of Bannon, who declared war on the party’s establishment after leaving the White House earlier in the year, dismissed the loss as little more than a temporary setback that would soon be forgotten. Republicans cheering Moore’s loss, they said, would simply enrage Trump’s most loyal supporters nationwide, who already suspected some Republican leaders were trying to undermine the president’s agenda.

“They’re stomping on the very base they need to turn out for their candidates in the general election in 2018,” said Andy Surabian, a senior adviser to the Bannon-backed Great America PAC. He contended that “the average Republican voter across the country is pointing their finger at Mitch McConnell and the Republican establishment.”

Conservative activist Mark Meckler did just that.

“One hundred percent of this I hang around Mitch McConnell’s neck,” said Meckler, an early tea party leader, referring to the mainstream Republican who is Senate majority leader.

At the same time, the Alabama contest sounded an undeniable alarm for Republican officials charged with defending the party’s majorities in the House and Senate next year. Under the weight of Trump’s historically low approval ratings, Alabama put their concerns on steroids.

“This was a wake-up-and-smell-the-coffee moment,” said Steven Law, who leads the Senate Leadership Fund, which is aligned with Senate GOP leaders. He said Alabama’s election, like recent contests in Virginia and New Jersey, demonstrated “sky-high Democratic enthusiasm.”

“Republicans are going to have to put forward top-quality candidates and run flawless campaigns to win next year even in states that trend Republican,” Law said.

In the shorter term, it’s unclear how the loss will affect the Republicans’ governing agenda.

When Jones is sworn into office — likely in early January — the GOP’s Senate majority will shrink to pinhole-sized 51-49. That increases pressure on Republicans to push their prized $1.5 trillion tax bill through Congress before lawmakers leave town late this month, a goal they seem likely to achieve.

The narrowing majority gives extra leverage to Republicans like moderate Maine Sen. Susan Collins, who’s extracted leadership promises for accompanying legislation shoring up parts of the “Obamacare” health care law. Collins told reporters Wednesday she was confident those promises would be kept.

“All you cynics in the press will have to be eating crow come Dec. 31,” she said.

Yet Republicans cannot abandon their policy priorities after taxes if they hope to generate momentum heading into the midterms, said Tim Phillips, president of the Koch Brothers-backed Americans for Prosperity.

“Taxes are a crucial start, but they’re going to need to do more,” he said. Jones’ victory could complicate the GOP’s goals, Phillips said, particularly “if he goes the partisan resistance route.”

“If he does, then clearly it’s one less vote and it will make things more difficult,” he added.

The GOP already faced an uphill battle for any major legislative achievements in the near term.

Some Republicans, particularly House leaders, have talked about a drive to overhaul Medicare, Medicaid and welfare programs next year. Even if the GOP succeeds in approving special rules that would require just 50 votes, some Republicans are leery of cutting popular programs in an election year and the chances of success seem low. Democrats would oppose any such effort.

Other initiatives, like a huge program to upgrade the nation’s infrastructure, would need 60 Senate votes to succeed. Barring a GOP effort to craft bipartisan bills from the start, it seems unlikely nine Democrats would defect to back a Republican-written version with elections on the horizon.

Democratic National Committee Chairman Tom Perez hailed the Alabama result as a harbinger of what’s to come.

“Last night was not a fluke, it was a message,” he told reporters on a conference call. “The days of Donald Trump are numbered.”

___

Associated Press writers Kevin Freking, Matthew Daly and Zeke Miller in Washington, and Bill Barrow in Montgomery, Alabama contributed to this report.