MONTGOMERY, Ala. — Democrat Doug Jones will be Alabama’s next senator after one of the wildest races in recent memory, giving Democrats a crucial seat in the chamber and opening a real if narrow path to retaking Senate control next year.

Jones led accused child molester and GOP nominee Roy Moore by 49.6 percent to 48.8 percent with 89 percent of precincts reporting, according to the New York Times returns. The Associated Press has called the race, as have several TV networks.

Jones’s improbable victory was made possible when multiple women came forward to accuse Moore of sexual misconduct towards them when they were teenagers. Those allegations plunged the race into chaos and gave his party a rare chance at seriously contesting a race in deep red Alabama, where no Democrat has won a major statewide office since 2006.

His win narrows Republicans’ edge in the Senate to 51-49, leaving even less room for error on legislation and giving Democrats a real chance at winning back control of the chamber next year in spite of a brutal map where they’re mostly on defense.

Democrats now just need to hold serve in the 10 states that Trump won where they’re defending incumbents, and pick up swing-state Nevada and Arizona, to win back control. That appears doable if tough in the current political environment.

The result is likely to further inflame tensions between Senate Majority Leader Mitch McConnell (R-KY) and President Trump. McConnell disavowed Moore’s campaign, called for him to drop out and refused to spend to help him after the allegations surfaced, while Trump rode to his rescue with rallies and money from the Republican National Committee after refusing to help push him out of the race. Both will likely blame the other for the disastrous result, further fueling fights within the party that will play out in a number of Senate primaries.

It’s also a blow to former White House chief strategist Steve Bannon, who threw his support hard behind Moore in the primary and stuck by him through the race. Bannon has promised support to a rash of populist firebrands in GOP primaries, but it might be harder to convince voters to back his candidates after the debacle in Alabama, where he was one of Moore’s most visible supporters.

The infighting between the factions began even before final results were in — and escalated as soon as the race was called for Jones.

“This is a brutal reminder that candidate quality matters regardless of where you are running,” Steven Law, the head of the pro-McConnell Senate Leadership Fund, said in a statement immediately after the AP called the race. “Not only did Steve Bannon cost us a critical Senate seat in one of the most Republican states in the country, but he also dragged the President of the United States into his fiasco.” National Republican Senatorial Committee Chairman Cory Gardner (R-CO) was direct, saying Alabama voters “deemed Roy Moore unfit to serve” before calling on Jones to vote with the GOP. Trump himself was gracious in his loss. Congratulations to Doug Jones on a hard fought victory. The write-in votes played a very big factor, but a win is a win. The people of Alabama are great, and the Republicans will have another shot at this seat in a very short period of time. It never ends! — Donald J. Trump (@realDonaldTrump) December 13, 2017

But some of his supporters weren’t happy.

“I hate the fact that Doug Jones ran a gutter-style campaign instead of addressing the issues. This man hasn’t been charged with anything, he’s always been a man of faith,” Trump Alabama state chairman Perry Hooper, who was at the Moore election event, told TPM.

Hooper then turned on Sen. Richard Shelby (R-AL), the most prominent Alabama Republican who publicly refused to back Moore.

“It’s upsetting being a Trump guy, it’s a setback to Alabama… and there’s a lot of people upset with Sen. Shelby, I’ll tell you that,” he said.

Democrats were jubilant — starting with Jones.

Thank you ALABAMA!! — Doug Jones (@DougJones) December 13, 2017

“We have shown the country the way that we can be unified. … At the end of the day, this entire race has been about dignity and respect,” Jones said to a jubilant crowd in Birmingham. “This campaign has been about common courtesy and decency, and making sure everyone in this state, regardless of which zip code you live in, is going to get a fair shake in life.”

But even after the race was clearly over, Moore’s campaign wasn’t ready to concede defeat.

“Some people have called the race. We’re not calling it yet. … And it could be a while,” Moore adviser Rich Hobson said at 9:40 p.m. central time before asking supporters to pray.

Jones is a relatively liberal Democrat who’s likely to stand with his party on most issues for the next few years. He’s pro-choice, believes in climate change and holds progressive views on civil rights, LGBT rights and immigration.

He’s also been critical of the GOP tax bill, putting additional pressure on Republicans to pass the legislation before the end of the year, when he’ll replace appointed Sen. Luther Strange (R-AL) in Congress. Strange was appointed to the seat when President Trump picked Jeff Sessions to lead the Department of Justice, and lost to Moore in the primary in spite of huge spending by McConnell and his allies.

Jones is a former U.S. attorney who is best known in Alabama for successfully reopening a decades-old case and prosecuting the Ku Klux Klansmen who bombed a Birmingham church in 1963, killing four little girls.