Brian Lyman and Paul Singer

USA TODAY Network

MONTGOMERY, Ala. — Democrat Doug Jones scored a shocking upset in the Alabama Senate race Tuesday, narrowly capturing a seat for Democrats in one of the reddest states in the nation.

Jones won with a margin of not quite 2 percentage points, narrowly besting Republican Roy Moore, who fought allegations that he had molested or pursued relationships with teenage girls in the 1970s when he was in his 30s and an assistant district attorney.

Moore did not concede and told supporters he would "wait on God and let this process play out."

"It's not over," he said, suggesting a recount was still possible. Alabama law allows for an automatic recount if the margin of victory is less than 0.5%.

But Alabama Secretary of State John Merrill said Tuesday on CNN it was “highly unlikely” that a recount of the votes would change the outcome of the special election.

Moore won the support of President Trump, but it wasn't enough for a majority of the roughly 25 percent of Alabama voters who participated in Tuesday's election.

Analysis:Jones victory a boost for Democrats — and some Republicans

Democrats had not even fielded a candidate for the seat when then-Sen. Jeff Sessions ran for re-election three years ago.

“I am truly overwhelmed," Jones said in his victory speech Tuesday night. "“This entire race has been about dignity and respect. This campaign has been about the rule of law. 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 gonna get a fair shake in life.”

More:Doug Jones celebrated both victory and his wedding anniversary on Dec. 12

Jones also noted that he and his wife, Louise, celebrated their 25th wedding anniversary Tuesday.

Jones’ win over Moore spares Senate Republicans the embarrassment and political fallout of having to call for an ethics investigation of their newest member.

"Decency wins," tweeted Republican Sen. Jeff Flake of Arizona, who announced his resignation in October with a scathing speech denouncing Trump for what he called “a flagrant disregard for truth or decency.”

'Decency wins':Emotional reactions to Jones' win over Moore erupt on Twitter

Jones's victory isn't good news for Trump, whose favored candidates have now twice lost in Alabama. Trump initially endorsed Sen. Luther Strange, who was appointed in February to fill the seat left vacant when Sessions became Trump's attorney general but then lost to Moore in the summer’s primaries. Trump's former chief strategist Steve Bannon had backed Moore from the beginning, and urged Trump to do the same.

Democrats also won several elections in November, including a closely watched governor's race in Virginia, an outcome that has been seen as a referendum on Trump's presidency.

Trump congratulated Jones in an uncharacteristically measured tweet, but noted that Republicans could win back the seat in 2020.

Trump also noted that "write-in votes played a very big factor;" several top Repubclians including Alabama's other senator, Richard Shelby, indicated they were going to write in another candidate. More than 22,000 votes were recorded for write-ins, exceeding the margin of Jones' victory.

Republicans began the year holding a thin 52-48 majority in the Senate and they have struggled to generate enough support in their own party to pass key legislative priorities like repealing the Affordable Care Act. With Jones taking a Republican seat, the majority is now 51 and Senate Majority Leader Mitch McConnell’s task became harder.

Black voter turnout was critical to Jones' victory, and black celebrities like former NBA star Charles Barkley and director Spike Lee weighed in for Jones, who prosecuted the Ku Klux Klan for the Birmingham church bombing in 1963 that killed four black girls.

The two campaigns pursued different strategies. Jones needed to build a coalition of base Democratic voters and suburban Republicans, particularly Republican women who in the past have been unenthusiastic about Moore. He campaigned on themes of jobs and economic opportunity.

Jones hit his polling location near Birmingham early Tuesday, smiling for the cameras and onlooking voters.

"This is an important time in Alabama's history, and we feel very confident where we are and how this is going to turn out," he said.

Moore, as is his tradition, arrived to vote on horseback.

With Bannon and his allies firmly behind him, Moore ran a campaign not unlike his previous statewide ones, with an emphasis on getting his loyal base of conservative Christian voters to the polls. In his public appearances, he stressed returning religion to the public sphere and attacked lesbian, gay, bisexual and transgender rights with a particular emphasis in this campaign on transgender individuals.

Opinion:Now that Roy Moore has lost, he can demand his day in court

List:Here are the Republican leaders who opposed Roy Moore

Moore repeatedly highlighted Trump’s decision to ban transgender people from the military. Yet the Pentagon confirmed Monday that it will begin accepting transgender troops Jan. 1, complying with a federal court order that overrules Trump's pledge.

Andrew Surabian, a close ally of Bannon’s, blamed the Republican establishment for Moore's defeat. “Mitch McConnell, the Senate Leadership Fund and the establishment got what they want in Alabama," Surabian told USA TODAY. "They delivered the seat to a liberal Democrat,” he said.

Follow Brian Lyman on Twitter: @lyman_brian

Contributing: Associated Press, Nicole Gaudiano, Deborah Barfield Berry.