MIDLAND CITY, US - After weeks of scandal and Republican Party hand-wringing, Alabama voters went to the polls Tuesday in a Senate contest between a Republican accused of once preying on teenage girls, and a Democrat seeking an upset win in this deeply conservative state.

US President Donald Trump has made the special election a test of his brand of populism by urging loyalists to elect Republican firebrand Roy Moore, an ultra-conservative former judge who has been the focus of the race from the start.

Moore, who wants to bring his religious activism to the US Senate, has for the past month been fighting accusations he fondled two underage girls in the late 1970s when he was a state prosecutor in his 30s.

The scandal has put a Senate seat from Alabama within reach of Democrats for the first time in a quarter century.

And it has created a major headache for Republicans. The party's leaders and members of Congress called on Moore to step down after the allegations first surfaced, to no avail. Now, regardless of the outcome, they face a no-win situation.If Moore wins, the Republican brand risks being sullied by association with the judge, particularly at a moment when the country is in the midst of a social upheaval over sexual harassment and the right of victims to be heard.

"Roy Moore will be the gift that keeps on giving for Democrats," Senator Lindsey Graham, a Republican from South Carolina, told CNN.

If Moore loses, Republicans will see their US Senate majority eroded, slipping from 52 to 51 seats out of 100 and reducing the GOP's margin for maneuver to the bare minimum.

Polls opened across the state at 7:00 am, and are scheduled to close at 7:00 pm (1300 to 0100 GMT).

To protect that precious seat, Trump ultimately endorsed Moore - throwing caution to the wind for the 2018 mid-term elections, and for the party's image. "I need Alabama to go vote for Roy Moore," Trump said in a robo-call to Alabama voters on Monday.

Trump's former chief strategist, Steve Bannon, has thrown his weight behind Moore in what he has depicted as a battle against a Republican "establishment" out to thwart the Trump revolution.

The Democratic candidate, Doug Jones, received support from former president Barack Obama, who made his own robo-call in a state where the African-American vote could prove decisive.

"This one's serious. You can't sit it out," Obama said in the call. "So get out and vote, Alabama ."

The latest survey by Fox News put the Democrat Jones ahead by 10 points, although a new Emerson poll has Moore ahead by nearly that much. The two are competing to replace Jeff Sessions, who become US attorney general.

The campaign, the first for a Senate seat since Trump's election, has been memorably virulent, in a state accustomed to rough politics.

Ostracized by his own party, Moore has taken a page from Trump's playbook, rejecting the women's allegations as "fake news," a slogan his supporters repeat with relish.

In addition to being hostile to abortion, gays and transgenders, he has attacked illegal immigration and voiced support for a strong defense, presenting himself as a reliable partner to Trump.

"It's difficult to drain the swamp when you're up to your neck in alligators. And that's where we are," Moore said in his final campaign rally in this town in rural Alabama .

"We're up to our neck in people that don't want change in Washington DC," he said.

His wife Kayla, defended her husband's honor and rejected accusations of racism, sexism and anti-Semitism. "One of our attorneys is a Jew," she said.

Democrats have invested heavily in the battle. Thanks to an avalanche of donations, they have flooded the airwaves with TV ads, and deployed leading black Democrats to mobilize the African American vote - about a quarter of the electorate.

Jones, a 63-year-old former federal prosecutor, has also tried to win over moderate Republicans and upper middle class voters repelled by the accusations against Moore.

"This election is going to be one of the most significant in our state's history," Jones told a cheering crowd in Birmingham.

"It is time that we put our decency, our state, before a political party."

Jones is known for having convicted two Ku Klux Klan members for bombing a black church in Birmingham, killing four African-American girls.

His support for abortion rights, however, is anathema to many conservatives, who may choose to write in another candidate aside from the two on the ballot.

And in deeply conservative Alabama , people are loyal to their president and their party.

Roy Moore is "innocent until proven guilty," says Katie Cunningham, a 48-year-old nurse at Moore's rally in Midland City, without a second's hesitation. "We support Trump, we are Republicans, we support him to the end. No matter what."