Doug Jones made an appeal for "decency" to prevail over partisanship. Deeply conservative Alabama apparently listened, overturning a quarter-century of voting habits to elect him on Tuesday night in a stunning rebuff of the president, of an anti-establishment insurgency and of sexual harassment in Congress, Alabama politicos said.

Jones, a former prosecutor, became the first Democrat in 25 years from the deeply red state to be elected to the U.S. Senate seat, edging out his Republican rival Roy Moore, an accused child molester and Bible-quoting former judge, in a test of the limits of political tribalism.

Jones's upset victory on reliably red soil suggested Moore's alleged sexual predation of teen girls when the ex-jurist was in his thirties may have been too much for Republican voters to stomach.

Moore denies the allegations.

'Voters will only be pushed so far'

"Turnout didn't decide the election," tweeted Republican Alabama strategist Blake Harris, noting that some 22,000 votes were recorded as write-ins for alternative candidates. "Republicans who showed up but who couldn't bring themselves to vote for Moore decided it."

"This shows there are limitations to partisanship. Even in a Republican state," Zac McCrary, a Democratic pollster, said from Jones's Birmingham victory party. "Voters will only be pushed so far. And then they push back. That's what happened tonight."

Republican U.S. Senate candidate Roy Moore pauses as he addresses supporters at his election night party in Montgomery, Ala. Moore's loss spells trouble for the so-called Trump effect. (Carlo Allegri/Reuters)

He said Alabamians were tired of being "embarrassed" by politicians.

For U.S. President Donald Trump, the upset victory by Jones throws into doubt the value of his political capital, with the commander-in-chief now 0-2 in Alabama Senate races. Trump supported Republican candidate Luther Strange in the primary before Strange lost to Moore. Trump then endorsed Moore, to no avail.

The result spells trouble for the so-called Trump effect, said Joseph Smith, chair of the political science department at the University of Alabama.

"Donald Trump is not a kingmaker," he said. "He does not have enough influence over voters to change races."

'Earth-shaking for Alabama'

Establishment Republican lawmakers who felt pressured for the sake of their seats to abide by the president's agenda might now feel more emboldened to buck some of his policies, as well as the populist movement within the party, Smith said.

"This changes the calculus for current Republican senators," he said, "because I think they'll be less fearful of primary challenges" being boosted by Breitbart Media rabble rouser Steve Bannon.

The Democratic party has been "dead" in Alabama state-wide elections for a quarter of a century, Smith noted. "So to win this state-wide race is earth-shaking for Alabama."

Political strategist Stephen Bannon speaks at a Moore campaign rally in Midland City, Ala., on Monday. (Carlo Allegri/Reuters)

"If Steve Bannon and Donald Trump couldn't produce a winner in Alabama, you have to wonder if they can produce a winner anywhere."

Republican Alabama strategist Jonathan Gray sees a clear opportunity for Democrats.

Republicans now have an even slimmer margin for error, with 51 seats to the Democrats' 49. Losing two votes could doom their legislative efforts, including their top legislative priority: Tax reform.

'Realistic path' to victory for Democrats

Meanwhile, Democratic prospects for reclaiming a Senate majority now appear brighter for next year's midterm elections.

To his chagrin, Gray said, Democrats can "absolutely" retake the Senate in November 2018. Republican-held seats in Arizona, Tennessee and Nevada could be in play for Democrats next year.

Supporters celebrate at Jones's election night party. (Marvin Gentry/Reuters)

McCrary, the pollster, said Democrats have at minimum a "realistic path" to a Senate majority, "which, six months ago, was very much in question."

Trump congratulated Jones in a tweet. However, Moore refused to concede defeat in the down-to-the-wire election, even though the numbers required to trigger a recount were "highly unlikely," in the words of Alabama's secretary of state.

Roy Moore is waiting until all votes are counted before admitting Jones win 0:33