BIRMINGHAM, Ala. — He has ignored all the rules of modern-day politics.

He speaks unscripted. He skimps on fundraising. He undervalues get-out-the-vote efforts. And he attacks the leaders of his own political party without mercy.

A year ago, that was presidential nominee Donald Trump. This year, it's Senate candidate Roy Moore.

On the ground in Alabama, some believe the Republican Moore is poised to win the state's special election Tuesday in a race that features extraordinary parallels with Trump's White House run. Against all odds, Moore has weathered sexual misconduct allegations while applying the same unorthodox playbook that many political operatives said wouldn't work for anyone but Trump.

"Trump was a rejection of the elite, and I think a lot of folks were hopeful that was a one-time glitch in the system," said Republican operative Andy Surabian, who worked for the Trump campaign last year and now advises a super PAC working to elect Moore. "But it was really an indicator of a long-term trend that's playing out now in Alabama."

Like most of the GOP establishment, Trump avoided the Alabama race for much of the last month as allegations of sexual misconduct mounted against the Republican candidate. But in the campaign's final weekend, the Republican president is engaged and fighting to rally voters behind his anti-establishment ally.

"LAST thing the Make America Great Again Agenda needs is a Liberal Democrat in Senate where we have so little margin for victory already," Trump tweeted Friday about Moore's Democratic opponent, Doug Jones, hours before he was set to hold a campaign-style rally along the Florida-Alabama border. Trump added, "VOTE ROY MOORE!"

Moore likened himself to Trump in a last-minute ad ahead of Tuesday's contest. In the ad, Moore says the same "Washington insiders" that tried to stop Trump, are trying to stop him.

Whether by design or coincidence, Moore's candidacy has tracked Trump's in more ways than one.

Both men were badly outspent by the competition. Hillary Clinton and her Democratic allies doubled the spending by Trump and his Republican team. In Alabama, the spending disparity is even greater in favor of Democratic candidate Doug Jones.

Like Trump, Moore's fundraising troubles left him with a bare-bones campaign operation with little comprehensive plan to identify his voters and ensure they get to the polls on Election Day.

Both men have also been marred by scandal.

Just 32 days before the 2016 election, The Washington Post published the "Access Hollywood" video in which Trump admits to sexual predatory behavior. Several women came forward in the following days with detailed accusations of sexual misconduct dating back decades in some cases.

And 33 days before Alabama's 2017 election, The Washington Post published its first story about Moore's accusers, including one woman who said she was 14 when Moore, then a 30-something deputy district attorney, took off her shirt and pants and touched her over her underwear. Several more women came forward in subsequent days with detailed accusations of sexual misconduct.

In both cases, a chorus of Washington Republicans quickly called on the men to quit the race. The candidates responded by denying any wrongdoing and attacking the media and their critics in the party elite. And as Election Day neared, the Republican opposition softened.

Each man survived by converting his shortcomings into political strength as an anti-establishment fervor swept through the electorate.

Moore, like Trump before him, cast his fundraising problems and misconduct allegations as evidence that the Washington establishment was plotting against him. And many voters, already frustrated with national politicians, liked it.

"You see a lot of parallels with Trump. They're both very emotionally driven candidacies. They speak to voters' anger and disgust with Washington and the status quo," said Terry Sullivan, the campaign manager for Marco Rubio's presidential campaign. "Frankly, the Republican establishment is helping Roy Moore by opposing him."

As in Trump's case, college-educated voters and minorities will play an oversized role in Moore's race.

Trump's personal brand and the sexual harassment allegations alienated many women and college-educated voters nationally. At the same time, Clinton struggled to persuade black and Hispanic voters to rally behind her candidacy, which helped Trump eke out a narrow victory.

The Jones campaign has devoted extraordinary resources to targeting black voters and college-educated suburban Republicans across Alabama in recent weeks. Whether such voters turn out in strong numbers will largely determine Moore's fate.

"We're able in Alabama to get out there and talk to the voters and tell Doug Jones' story, and we're getting great response," said Giles Perkins, Jones' campaign chairman. "I don't know what kind of campaign Roy Moore has."

Moore was a little-known circuit judge when a decision to decorate his courtroom with a handmade wooden Ten Commandments plaque led to his political ascent.

The American Civil Liberties Union unsuccessfully sued him, and the fame helped catapult him to the position of chief justice of the State Supreme Court in the 2000 election. Arguing he had a right to "acknowledge God," he installed a boulder-sized Ten Commandments monument in the state court building. A judicial discipline panel later removed him from office after he disobeyed a federal court order to remove it.

After failed runs for governor, he was re-elected as chief justice in 2012 and quickly found a new fight: same-sex marriage. He was permanently suspended from the post in 2015 for urging state probate judges to thwart federal court decisions and refuse marriage licenses to same-sex couples.

Moore developed both a passionate following among evangelical Christians and a prickly relationship with the GOP's more-moderate business wing. Just like Trump.

"Donald Trump did one of the most tremendous things I think anyone could do. He fought both the Republicans and the Democrats to become the president of the United States," Moore told voters in Fairhope, Alabama this week.

"I remember when he was elected, I felt like a big weight had been taken off my shoulders. It felt like we had another chance," he said before turning to his own campaign. "And we do have another chance."

Chandler reported from Montgomery, Alabama.