Updated

Democrat Doug Jones has pulled off a major upset in Alabama by defeating Republican Roy Moore in Tuesday’s special election, becoming the first Democrat to win election to the Senate from the deeply conservative state in 25 years.

"We have come so far and the people of Alabama have spoken," Jones said during a victory speech in Birmingham late Tuesday.

But in a late-night speech to supporters, Moore refused to concede. Moore told the crowd that when the “vote is this close…it’s not over.”

With 100 percent of precincts reporting, Jones had 49.9 percent to Moore's 48.4 percent.

Moore said the campaign was looking into the state's "recount provision." Under Alabama law, a mandatory recount takes place if a candidate wins by a half percentage point or less.

“We also know that God is always in control,” he said.

Bill Armistead, his campaign chairman, floated a possible recount late Tuesday.

Other Republicans, though, already accepted the outcome. In a tweet, President Trump congratulated Jones on his “hard fought victory.”

“The write-in votes played a very big factor, but a win is a win,” Trump said. “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!”

A Democrat winning the special election for the seat to replace Attorney General Jeff Sessions was seen as just a remote possibility several months ago.

doug jones

Doug Jones, an attorney best known for prosecuting two members of the KKK for the 1963 bombing of the 16th Street Baptist Church in Birmingham, initially wasn’t believed to have a realistic chance of winning the seat. Alabama hasn’t elected a Democrat to the Senate in 25 years. (AP)

But Jones, a Birmingham attorney famous for prosecuting the KKK, caught a break after Moore was overwhelmed in recent weeks with multiple allegations of past sexual misconduct. Moore denied the accusations throughout the race.

Moore, the former chief justice of Alabama’s Supreme Court, has faced multiple allegations he pursued romantic relationships with teenage girls while he was in his thirties -- accusations that have dramatically shaken up the race. He has denied the claims.

The Fox News Voter Analysis, a new polling technique Fox News is testing to improve coverage, indicated 51 percent of voters on Tuesday believed the accusations against Moore.

The analysis also showed that 59 percent of voters thought Jones has strong moral character, while 57 percent said Moore doesn’t.

The dramatic Democratic win cuts the GOP’s Senate majority from 52 to 51, further dimming Republican hopes of enacting major legislation backed by President Trump. Jones likely won't be seated in Congress until January.

Because he is filling the rest of Sessions' term, Jones will not serve a full six year Senate term. The seat will be up for re-election again in 2020.

roy moore ap

Roy Moore, a favorite of religious conservative voters with a long, colorful political history that has both fueled and complicated his rise in Alabama. (AP)

Earlier in the day, Trump, who endorsed Moore even as other top Republicans in Washington called on the nominee to drop out of the race, on Tuesday reiterated his support by arguing Moore would vote for his agenda in Congress.

“The people of Alabama will do the right thing... Roy Moore will always vote with us,” the president tweeted.

Trump painted Jones as a liberal “puppet” of Democratic leaders Chuck Schumer and Nancy Pelosi.

“Doug Jones is Pro-Abortion, weak on Crime, Military and Illegal Immigration, Bad for Gun Owners and Veterans and against the WALL,” Trump tweeted.

Trump won 62 percent of Alabama’s vote in the 2016 presidential race.

Most of the attention in the race, though, centered on Moore. A favorite of religious conservative voters, he has a colorful political history that has both fueled and complicated his rise in Alabama.

He first got national attention in the 1990s as a county judge when he hung a wooden Ten Commandments plaque on the wall of his courtroom.

Benefiting from his popularity after the episode, Moore then ran and won a race for chief justice of the state’s Supreme Court in 2000. But he was ousted after refusing to remove a 5,280-pound granite Ten Commandments monument from the rotunda of the state judicial building.

He resurrected his political career in 2012, getting elected chief justice again. But his tenure was short-lived once more: In 2016, Moore was suspended as chief justice after he directed probate judges not to issue marriage certificates to gay couples.

After Sessions’ resignation, Luther Strange, the state’s former attorney general, was temporarily appointed to the seat in April before a special election could take place. Strange was appointed by then-Gov. Robert Bentley, who later resigned in the cloud of a scandal.

Despite being endorsed by Trump and enjoying the support of a well-funded super PAC connected to Senate majority leader Mitch McConnell, Strange went on to lose a runoff to Moore in September.

Last month, though, Moore was hit with multiple allegations that he initiated sexual encounters with teenagers when he was a young attorney in the 1970s.

McConnell called on Moore to drop out of the race and explored options for either removing Moore from the ballot or backing a write-in alternative. He also suggested Moore would face a Senate Ethics Committee investigation had he won.

Colorado Sen. Cory Gardner, the chairman of the National Republican Senatorial Committee, had said the Senate could take the extraordinary step of voting to remove Moore if he had won.

Alabama’s senior Republican senator, Richard Shelby, said he didn’t vote for Moore and instead wrote in the name of another Republican.

Moore, though, never backed down amid the accusations, holding multiple rallies with Trump’s former adviser, Steve Bannon, in recent weeks.

“I’m not talking about the accusers today,” Moore said after arriving at his polling location in Gallant, Alabama, on Tuesday. “I’m talking about this race... the people will answer the allegations this evening with the vote.”

Fox News’ Peter Doocy, Willie Inman, Dan Gallo and Fox Business’ Hillary Vaughn contributed to this report